HTML--the difference between get and post submission methods--

Source: Internet
Author: User
Tags html header http post

In the process of writing code, get and post are two different ways of committing. Below, the two different ways are listed.

Method/Step

  1. Get is the data that is fetched from the server, and post is the data that is sent to the server.

  2. Get is the URL where the parameter data queue is added to the Action property of the submission form, and the value corresponds to the field one by one in the form, which is visible in the URL. Post is the HTTP post mechanism that places the fields within the form with their contents in the HTML header, along with the URL address referred to by the Action property. The user does not see the process.

  3. For the Get method, the server side uses Request.QueryString to get the value of the variable, and for post, the server side uses Request.Form to get the submitted data.

  4. Get transmits a small amount of data and cannot be greater than 2KB. Post transmits a large amount of data, which is generally not restricted by default. In theory, however, the maximum amount of IIS4 is 100KB in 80KB,IIS5.

  5. Get security is very low and post security is high.

  6. 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 obtain information 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 the POST request, because the site is different after the comment submission

  7. 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, and the data submitted by the Get method can only have 1024 bytes, while post does not have this limit.

    Other Notes:

    Get mode to explicitly submit the form, you can see the parameters in the URL (address bar) We pass

    The Post method is an implicit pass-through value and is not visible.

    Comprehensive comparison of HTTP GET and Post methods

    --Basic information

    Property

    Get method

    Post method

    History:

    Usually the data sent using the Get method is saved as part of the URL by the browser.

    Data submitted using the Post method will not be part of the URL, but will not be saved by the browser.

    Bookmark:

    The Get method may be saved by the browser as a bookmark (bookmark)

    The Post method does not

    Fallback and resubmit:

    Pages that use the Get method can be rolled back and re-executed without notifying the user

    The Post method notifies the user to submit again

    Form encoding Type:

    Get submit data only supports

    application/x-www-form-urlencoded

    Post Support application/x-www-form-urlencoded and Multipart/form-data

    Parameters:

    Because the get parameters are usually followed by the URL, the supported data size is generally 2K, some servers can support to 64K. This is the real reason why many Web pages hang out over 64K. Because the server is limited.

    Send a parameter, or it can be a file, the size is theoretically unlimited.

    Being attacked:

    The Get method submits data that is easily hacked and implemented by scripting abductions.

    Post method is less susceptible to hacking than get methods

    Data type Restrictions:

    Get method submission data can only be text data

    The Post method is unrestricted, and the binary file is also available.

    Security:

    The Get method is less secure than the Post method because the data is visible as part of the URL. and the browser has historical access records.

    The Post method has a higher security relative to get. Because the parameter data cannot be stored in the history access record by the browser as part of the URL.

    form data Length:

    Because the form data is part of the URL, the URL length is usually limited.

    There is no limit to the Post method.

    Availability of:

    The Get method is not typically used to send passwords with sensitive information. But I found that there are still a lot of sites with get to implement login. such as the XXXX community, it put the login method in a jquery complete JavaScript script, with a GET request to complete.

    The Post method can be used to send passwords and other sensitive information.

    Visibility of:

    The Get method is visible to all people

    The variables of the Post method are not visible in the URL

    Cache:

    The Get method is cached by default, which is why it is often time to use the Get method to get the data behind a timestamp.

    The Post method is not cached by default.

    Unless the response header sets the Cache-control or Expires property value.

    Maximum value of the variable:

    Get support is 7,607 characters maximum

    The Post method supports a maximum value of 8MB

    Application:

    Get the most commonly used occasions is to get the data, the browser gets the Web page when most of the implementation through the Get method, most browser download also use Get method to get the file

    Post is used primarily to submit data to the server.

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.