Home > other >  The get and post
The get and post

Time:10-23

From the standard point of view, the difference between the GET and POST are as follows:

GET used to GET information, is no side effect and is idempotent, and can be cached POST to modify the data on the server, there are side effects and must be idempotent, cache

Interview: the difference between the GET and POST detailed explanation

Differences between the GET and POST request message

The GET and POST only two kinds of requests in the HTTP protocol (similar), and HTTP protocol is based on the TCP/IP application layer protocols, regardless of the GET or POST, use the same transport layer protocol, so on the transport, there is no difference,

Message format, with no parameters, the biggest difference is that the first line of the method name is different, only few characters of different message

The first line of POST method request packet is this POST/url HTTP/1.1 the first line of the GET method request packet is GET/url HTTP/1.1

The difference with the parameters of The Times article? In the contract, the parameters of the GET method should be given in the url, POST method parameters should be placed in the body

For example, if the parameter is the name=Javanx, age=25,
The GET method of message is this

GET/updateInfo? Name=Javanx& Age=25 HTTP/1.1 Host: localhost (sample) chart is the headline for the article list request


Interview: the difference between the GET and POST detailed explanation
POST method of message is this

POST/updateInfo HTTP/1.1 Host: localhost content-type: application/x - WWW - form - urlencoded name=Javanx& Age=25 (sample)
Now we know that the two methods is essentially a TCP connection, there is no difference, but if we don't also can according to specifications, can be written on the URL parameter, and then USES the POST; Can also be written on the Body parameters, then USES the GET, of course, this requires server-side support,
The GET method parameters are fixed?

In the contract, we parameters are written in the book? Behind, use & amp; Break up,

We know that the analytical process is by getting the TCP data packet, with regular and other tools from the data for the Header and the Body, so as to extract parameter,

Such as the header in the request header to add token, to verify whether the user login permissions problems, such as,

That is to say, we can the agreed parameters method and just can explain out of a service, plus ca change,

The length of the GET method limit is how to return a responsibility?

Mentioned on the web browser address bar of input parameters is limited.

First clear, HTTP protocol did not limit the length of the Body and the URL, the URL limit is mostly the cause of the browser and the server,

Browser not reason, that the server is processing long URL consumes more resources, for the performance and safety, prevent malicious structure long URL to attack), can give a URL length limit,

POST method is safer than the GET method?

Some people say that the POST than GET safe, because the data is not visible in the address bar,

From the point of view of transmission, however, they are not safe, because HTTP is clear in the network transmission, caught, as long as in the network nodes can fully get the data packet,

If you want to secure transport, you only encryption, HTTPS,
POST method will produce two TCP packets?

Some mentioned in the article, the post will send the header and body separate, first send the header, the server returns a 100 status code to send the body,

The HTTP protocol is not specified in the POST will produce two TCP packets, and actual test (Chrome) found that the header and the body will not separate to send,

So, the header and body send the request method is part of the browser or framework, do not belong to the post will be behavior,
  • Related