Differences between http get/POST requests

Source: Internet
Author: User
Tags html header

1.HTTPRequest format:

<Request line>

<Headers>

<Blank line>

[<Request-body>]

InHTTPIn the request, the first line must be a request line (Request LineIs used to describe the request type, the resources to be accessed, andHTTPVersion. Followed by a header (Header) To indicate additional information to be used by the server. The header is followed by a blank line. After that, any other data can be added.[Called the subject (Body)].

2.GetAndPostDifferences

HTTPDefines different methods for interacting with the server. The most basic method isGetAndPost.

HTTP-GET and HTTP-POST are standard protocol verbs that use HTTP to encode and transmit variable name/variable value pair parameters and use the relevant request semantics. Each HTTP-GET and HTTP-post are composed of a series of HTTP request headers that define what the client requests from the server, and the response is composed of a series of HTTP Response Headers and response data, if the request is successful, return to the response.
The HTTP-GET transmits parameters in the format of urlencoded text that uses the MIME type application/X-WWW-form-urlencoded. Urlencoding is a character encoding that ensures that transmitted parameters are composed of compliant texts. For example, the encoding of a space is "% 20 ". Additional parameters can also be considered as a query string.
Like a HTTP-GET, HTTP-POST parameters are URL encoded. However, the variable name/variable value is not transmitted as part of the URL, but is transmitted within the actual HTTP request message.

(1) Get isSlave ServerObtainData, post isSend to serverData.

(1) on the client, Get in URL submit data and data in URL medium you can see it; post method, where data is stored HTML header internal submit.

(2) For the get method, the server usesRequest. querystringGet the value of the variable. For the POST method, the server usesRequest. FormObtain the submitted data.

(2)GetThe maximum amount of data submittedOnly1024Word Festival, AndPostThenNo such restriction.

(3)Security issues. As in (1).GetThe parameter willDisplayed on the address bar, AndPostNo. Therefore, if the data is a Chinese data and non-sensitive data, useGetIf the data entered by the user is not a Chinese character and contains sensitive data, usePostAs well.

Note: security means that this operation is used to obtain information instead of modifying information. Idempotence means the same URL The same results should be returned for multiple requests. The complete definition is not as strict as it looks. In other words, Get Requests generally do not have side effects. Basically, the goal is that when a user opens a link, she can be confident that the resource has not changed from her own perspective. For example, the front pages of news sites are constantly updated. Although the second request will return a different batch of news, this operation is still considered safe and idempotent because it always returns the current news. And vice versa. Post The request is not that easy. Post Indicates a request that may change the resources on the server. Take news sites as an example.ArticleThe annotation should be passed through Post Be realistic, because the site is already different after the annotation is submitted (for example, an annotation appears below the article ).

The following is a simple example to illustrate their differences:

<! -Submit the form through get and Post respectively -->
<Form action = "getpost. asp" method = "get">
<Input type = "text" name = "text" value ="Http://wxf0701.cnblogs.com//>
<Input type = "Submit" value = "Get mode"> </input>
</Form>
<Br>
<Form action = "getpost. asp" method = "Post">
<Input type = "text" name = "text" value ="Http://wxf0701.cnblogs.com/>
<Input type = "Submit" value = "post mode"> </input>
</Form>
<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 by post is: "<B> <% = request. Form (" text ") %> </B>" <br>
<% End if %>

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.