The difference between the GET and POST methods of HTTP requests

Source: Internet
Author: User

The difference between the GET and POST methods of HTTP requests

In the request-response between the client and the server, the two most commonly used methods are: GET and POST.

    • GET-Requests data from the specified resource.
    • POST-submits the data to be processed to the specified resource

Get method

Note that the query string (name/value pair) is sent in the URL of the GET request:

/test/demo_form.asp?name1=value1&name2=value2
    • Requests can be cached
    • Request remains in browser history
    • Requests can be bookmark-Favorites
    • The request should not be used when processing sensitive data
    • Request has a length limit
    • Requests should only be used to retrieve data

Post method

Note that the query string (name/value pair) is sent in the HTTP message body of the POST request:

POST /test/demo_form.asp HTTP/1.1Host: w3schools.comname1=value1&name2=value2

Compare GET to POST

Method GET POST
Cache can be cached Cannot be cached
Encoding type application/x-www-form-urlencoded Application/x-www-form-urlencoded or Multipart/form-data. Use multiple encodings for binary data.
Limits on the length of data Yes. The GET method adds data to the URL when the data is sent, and the length of the URL is restricted (the maximum URL length is 2048 characters) Unlimited.
Restrictions on data types Only ASCII characters are allowed There is no limit. Binary data is also allowed.
Security GET is less secure than POST because the data being sent is part of the URL. Never use GET when sending passwords or other sensitive information POST is more secure than GET because parameters are not saved in the browser history or Web server logs.
Visibility of The data is visible to everyone in the URL. The data is not displayed in the URL.

Other HTTP Request Methods

    • HEAD is the same as GET, but returns only the HTTP header and does not return the document body.
    • The PUT upload specifies the URI representation.
    • Delete Deletes the specified resource.
    • OPTIONS returns the HTTP methods supported by the server
    • Connect converts the request connection to a transparent TCP/IP channel.

The difference between the GET and POST methods of HTTP requests

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.