The use and difference of get,post,put,delete methods in HTTP

Source: Internet
Author: User
Tags browser cache

An HTTP protocol is a protocol that is followed in a network for file transfer. A stateless protocol, the HTTP protocol server side does not establish a long-term communication connection with the browser side. After the HTTP communication is established, the server sends the file contents to the browser side to complete the request. Of course a page, often composed of multiple HTTP requests, images, CSS and other resources request ~ may be a page after multiple HTTP requests to get results.

get: sends a request to get a resource on the server. Resources are returned to the client through a set of HTTP headers and rendering data (such as HTML text, or pictures or videos).

POST: submit data to the server.

The most intuitive difference:

1). Get parameters are included in the URL, post through the request body pass parameters;

2). Get is harmless when the browser is rolled back, and post submits the request again;

3). Get generated URL address can be bookmark, and post can not;

4). The GET request will be active by the browser cache, and post will not, unless manually set;

5). Get requests can only be URL-encoded, while post supports a variety of encoding methods;

6). The GET request parameters are kept intact in the browser history, and the parameters in the post are not retained;

7). A GET request has a length limit for the parameters that are passed in the URL, and there is no limit to post;

8). For data types of parameters, get accepts only ASCII characters, while Post has no restrictions;

9). Get is less secure than post because parameters are directly exposed to URLs, so they cannot be used to pass sensitive information;

Essential differences:

First get and post requests are both methods of sending requests in the HTTP protocol, and HTTP is a TCP/IP-based protocol on how data communicates in the World Wide Web, with TCP/IP at the bottom of HTTP. So the bottom of GET and post is TCP/IP, which means that get/post are TCP links. Get and post can do the same thing. You have to add the request body to the GET, and the URL parameter to the post, technically it's all in line.

1). While the theory that get and post requests can be used without distinction, different browsers (initiating HTTP requests) and servers (accepting HTTP requests) limit the risk of single-pass data, which is a huge burden on browsers and servers. The industry's unwritten rule is that (most) browsers typically limit URLs that are 2K bytes long, while (most) servers handle up to a 64K-size URL. Over the part that is not processed. If you use Get service, in the request body secretly HID data, different server processing method is also different, some servers will help you unload, read out data, some servers directly ignore, so, although get can take request body, there is no guarantee will be received.

2). Get generates a TCP packet; Post generates two TCP packets; For the Get mode request, the browser will send the HTTP header and data, the server response 200 (return data), and for post, the browser first sends the header, the server responds to the continue, the browser sends data, the server response 200 OK (return data). Because post takes two steps, it consumes a bit more time and looks like get is more efficient than post. So the Yahoo team recommends using get to replace post to optimize site performance.

Get and Post use note:

1). Get and Post have their own semantics and cannot be mixed.

2). According to the study, in a good network environment, the time to send a packet and two times the time difference between packets can be ignored. In the case of poor network environment, two packets TCP has a great advantage in verifying the integrity of packets.

3). Not all browsers will send two packets in post, and Firefox will send them only once.

The use and difference of get,post,put,delete methods in HTTP

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.