HTTP protocol Request Mode: Introduction to get, Post and head in, and error prompt code

Source: Internet
Author: User


Introduction to get, post, and head in the HTTP protocol
2008-05-10 14:15
GET: requests the specified page information and returns the entity Principal.
HEAD: only the header of the page is Requested.
POST: the requesting server accepts the specified document as a new subordinate entity for the identified Uri.
PUT: supersedes the contents of the specified document from the data that the client sends to the SERVER.
Delete: The requested server deletes the specified page.
OPTIONS: allow clients to view server Performance.
TRACE: the request server returns the resulting content in the entity body portion of the Response.
PATCH: The entity contains a table that describes the differences from the original content represented by the Uri.
Move: the requesting server moves the specified page to another network address.
Copy: the request server copies the specified page to another network address.
Link: request the server to establish a link relationship.
UNLINK: Break Link Relationship.
Wrapped: allows the client to send encapsulated Requests.
Extension-mothed: additional methods can be added without altering the Protocol.


GET: requests the specified page information and returns the entity Principal.
HEAD: only the header of the page is Requested.
POST: the requesting server accepts the specified document as a new subordinate entity for the identified Uri.





HTTP defines different ways to interact with the server, and the most basic method is GET and POST. In fact GET applies to most requests, while retaining POST is only used to update the Site. According to the HTTP specification, get is used for information acquisition and should be secure and idempotent. The so-called security means that the operation is used to rather than modify Information. In other words, GET requests generally should not have side effects. Idempotent means that multiple requests to the same URL should return the same result. The complete definition is not as strict as it seems. fundamentally, The goal is that when a user opens a link, she can be confident that the resource has not changed from its point of VIEW. For example, The front page of news sites is constantly being updated. Although the second request returns a different batch of news, the operation is still considered safe and idempotent, as it always returns the current News. Vice versa. The POST request is not that Easy. POST represents a request that might change resources on the Server. Still take the news site as an example, the Reader's comments on the article should be implemented through a post request, because the site is different after the comment is submitted (for example, A note appears below the article);
When the form is submitted, if you do not specify method, the default is a get request, and the data submitted in the form will be appended to the url, separated from the Url. The alphanumeric character is sent as is, but the space is converted to the "+" sign, and the other symbol is converted to%xx, where XX is the ASCII (or ISO Latin-1) value that the symbol is represented in 16 binary. The GET request submits the data to be placed in the HTTP request protocol header, and the data submitted by the post is placed in the entity data;
The Get method submits only 1024 bytes of data, while Post does not have this limit.

What is the difference between using "post" and "get" in the form?

In the form, you can use post or get. They are all legal values of METHOD. however, the Post and get methods are at least two points different on use:
1. The GET method passes the User's input through a URL Request. The Post method is in another form.
2, Get mode of submission you need to use Request.QueryString to get the value of the variable, and when the post is submitted, you have to access the submitted content through REQUEST.FORM.
Study the following code CAREFULLY. You can run it to feel:

Code
<!--two form only the method property is different--
<form action= "getpost.asp" method= "get" >
<input type= "text" name= "text" value= "Hello world" ></INPUT>
<input type= "submit" value= "method=get" ></INPUT>
</FORM>
<BR>
<form action= "getpost.asp" method= "post" >
<input type= "text" name= "text" value= "Hello world" ></INPUT>
<input type= "submit" value= "method=post" ></INPUT>
</FORM>

<BR>
<BR>

<% If request.querystring ("Text") <> "then%>
The string passed through the Get method is: "<b><%= request.querystring (" Text ")%></b>" <BR>
<% End If%>

<% If request.form ("Text") <> "then%>
The string passed through the Post method is: "<b><%= request.form (" Text ")%></b>" <BR>
<% End If%>

Description
Save the above code as getpost.asp, then run, First Test the post method, at this time, the browser URL does not change anything, the result is returned:
The string passed through the Post method is: "Hello world"
Then the test is submitted with the Get method, Note that the URL of the browser becomes:
Http://localhost/general/form/getpost.asp?Text=Hello+World
The result of the return is:
The string passed by the Get method is: "Hello world"
finally, through the Post method submission, the browser URL is:
Http://localhost/general/form/getpost.asp?Text=Hello+World
And the returned result Becomes:
The string passed by the Get method is: "Hello world"
The string passed through the Post method is: "Hello world"

Tips
Submitting data through the Get method can pose a security issue. such as a landing page. When data is submitted through the Get method, the user name and password appear on the Url. If:
1, The landing page can be cached by the browser;
2, Other people can access the Customer's machine.
Then someone can read the account number and password from the Browser's history. therefore, in some cases, the Get method poses a serious security problem.
Suggestions
The Post method is recommended for use in Form.



If the head method is requested, the server returns only the response header, not the requested block, and the head method is common to some search engines

--------------------------------------------------------------------------------------------------------------- -----

GET: requests the specified page information and returns the entity Principal.
HEAD: only the header of the page is Requested.
POST: the requesting server accepts the specified document as a new subordinate entity for the identified Uri.
PUT: supersedes the contents of the specified document from the data that the client sends to the SERVER.
Delete: The requested server deletes the specified page.
OPTIONS: allow clients to view server Performance.
TRACE: the request server returns the resulting content in the entity body portion of the Response.
PATCH: The entity contains a table that describes the differences from the original content represented by the Uri.
Move: the requesting server moves the specified page to another network address.
Copy: the request server copies the specified page to another network address.
Link: request the server to establish a link relationship.
UNLINK: Break Link Relationship.
Wrapped: allows the client to send encapsulated Requests.
Extension-mothed: additional methods can be added without altering the Protocol.

Like what:
Get/index.html http/1.1
accept:text/plain/* Plain ASCII text file */
accept:text/html/*html text File */
user-agent:mozilla/4.5 (WinNT)
Description The browser uses the Get method to request Document/index.html. The browser is only allowed to receive pure ASCII code text files and HTML text files, and the engine used is mozilla/4.5 (Netscape).

When the server responds, its status line information is the version number of the http, the status code, and a simple explanation of the status Code. 5 Types of status codes are listed in detail now:
① Client Side Error
100 continue
101 Exchange Protocol
② success
OK
201 Created
202 Reception
203 non-certified Information
204 No Content
205 Resetting Content
206 part of the content
③ redirection
300 Multi-channel selection
301 Permanent Transfer
302 Temporary transfer
303 See other
304 Unmodified (not Modified)
305 using Proxies
④ Client Side Error
400 Error Requests (bad Request)
401 Not certified
402 Fee Required
403 Prohibition (Forbidden)
404 Not Found (not Found)
405 method does not allow
406 Not Accepted
407 Requires agent authentication
408 Request timed out
409 conflicts
410 failure
411 Required Length
412 Pieces failed
413 Request Entity too large
414 Request URI too long
415 Media type not supported
⑤ Server Error
500 Server Internal Error
501 Not implemented (not Implemented)
502 Gateway Failure
504 Gateway Timeout
505 HTTP Version not supported
For Example: (in the "telnet ..." article with telnet to the 80 port, the same method used in the http/1.1, will find no display, the following supplementary Explanation)
Telnet www.fudan.edu.cn 80
head/http/1.1
host:www.fudan.edu.cn/* This behavior input */
http/1.1 501 Method Not implemented
date:web, 07:12:29 GMT/* Current Date/time */
server:apache/1.3.12 (Unix)/*web Server Information */
allow:get, HEAD, OPTION, TRACE/* supported method type */
Connection:close
connect-type:text/html; charset=iso-8859-1/* Media type of connection */

<! DOCTYPE HTML publig "-//ietf//dtd html 2.0//en" >
<HTML><HEAD>
<title>501 Method
Not implemented</title>
</HEAD><BODY>
Head To/inde
X.html not supported.<p>
Invalid method in Request head/htp/1.1<p>
<HR>
<ADDRESS>
apache/1.3.12 Server at www.fudan.edu.cn Port 80</address>
</BODY></HTML>
The contents of the entity head can also be:
Last Modified: the time when the document was requested for most recent Modification.
Expires: the time when the document was requested to Expire.
Connect-length: Length of document Data.
Www-authenricate: notifies the client of the required authentication Information.
Connect-encoding: Indicates if there is any use of compression technology.
Transfer-encoding: describes the type of encoding transformation Used.

With the development of the internet, the next generation of HTTP protocol Http-ng is already brewing, it will provide better security, faster speed, the main points for improvement are: strong modularity, High Network efficiency, Security and more simple structure.








Original Link: http://ymiter.iteye.com/blog/1922464



HTTP protocol Request Mode: Introduction to get, Post and head in, and error prompt code


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.