Interface test GET and POST are two basic differences HTTP request method

The interview can answer (usually A former 4 on the line):

  1. GET url passed parameters, POST request body placed in
  2. GET request parameters passed in the url is the length restricted, but no POST
  3. GET more secure than POST, because the parameters directly exposed on the URL, it can not be used to transmit sensitive information
  4. GET request parameters will remain intact in the browser history, and POST parameters will not be retained
  5. GET request can only be url encoded, and support multiple encoding POST
  6. GET requests are active cache browser, POST will not, unless manually set
  7. GET url address can be generated bookmark, and not POST
  8. GET fallback when the browser is harmless, and POST will submit the request again

Depth:

There is no difference between the GET and POST nature

What GET and POST are?

A: Two methods of sending a request in the HTTP protocol, a TCP connection is essentially

HTTP is what?

A: Hypertext Transfer Protocol. HTTP is based on TCP / IP protocol on how to communicate data on how the World Wide Web.

 

for example:

TCP like a car, we use TCP to transport data, it is very reliable, the phenomenon has never lost pieces of small pieces does not occur.

But if the road running all look exactly the same car, it seems like the world is a mess, courier delivered the car in front of the car might be loaded with goods stopped blocking the road, the entire transport system will be paralyzed.

To prevent this from happening, traffic rules HTTP born. HTTP transport to the car set several service categories, there are GET, POST, PUT, DELETE, and so on,

HTTP specifies that, when performing the GET request, give the car a label affixed GET (set to GET method), and requires the transfer of data on the roof (url) is to facilitate recording.

If POST request, POST will affix a label in the car, and the goods in the car. Of course, you can also go in the cabin GET secretly hidden point when the goods, but it is very disgraceful; can also put some data on the roof at POST when people feel silly.

HTTP is just a code of conduct, while TCP is GET and POST how to achieve basic.

 

However, we only see the HTTP GET and POST for delivery channels parameters (url or requrest body) made requests. "Standard answer" in the limit on the size of the parameter is from?

 

I World Wide Web at large in the world, there is another important role: transportation companies.

A different browser (http request initiated) and server (http accept the request) is different transportation companies.

Although theoretically, you could infinite stack of goods (url in unlimited additional parameters) on the roof. But the transportation company was no fool, loading and unloading is also a great cost, they will limit traffic to a single control risk, too much data to the browser and the server is a great burden.

It is the industry's unwritten regulations, (most) browsers usually limit url 2K bytes in length, and (most of) the size of the server process up to 64K url.

The part in excess will not be processed. If you use the GET service request body secretly hidden in the data, handling different servers is different, some servers will help you unload, read data, some simply ignore the server,

So, while you can GET with request body, it can not be guaranteed to be received, oh.

 

Well, now you know, the GET and POST essentially TCP link, and non-discriminatory. However, due to the provisions of HTTP and the browser / server, causing them to reflect some differences in the application process. 

Do you think this article Is this the end?

We are also waiting for the big BOSS played yet. . .

 

The BOSS How mysterious? When you are trying to find "the difference between GET and POST" on the Internet, those who search results you will see there, never mention him. What he really is it. . .

 

GET and there is a significant difference between the POST, simply say:

GET generates a TCP packet; generating the POST two TCP packets.

Long said:

For the GET request, the browser will http header and data sent together, the server response 200 (return data);

For POST, the browser transmits the first header, the server response 100 continue, the browser then transmits data, in response to the server 200 ok (return data).

 

In other words, GET only need to put the car trip to deliver the goods, while the POST have to run twice, the first trip, go to the server and say hello, "Hey, I want to wait for the next shipment to delivery, you open the door to greet me, "and then send the goods back to the past.

Because POST requires two steps, the time to consume a little more, it seems more effective than GET POST. So Yahoo team has recommended replacing POST with GET to optimize site performance. But this is a pit! Jumped into the need to be cautious. why?

1. GET and POST has its own semantics, not just mixed.

2. According to the research, time and time difference between the two packages sent in the network environment is good, send a package basically ignored. And in the case of poor network environment, TCP packets over the two packet integrity verification, there is great advantage.

3. Not all browsers will send two packets during POST, Firefox is sent only once.

 

Reference links:

https://www.cnblogs.com/songanwei/p/9387815.html

https://segmentfault.com/a/1190000009512784

https://www.cnblogs.com/lanmosonny/p/8881362.html

https://baijiahao.baidu.com/s?id=1626599028653203490&wfr=spider&for=pc

https://www.cnblogs.com/kexianting/p/8448539.html

Guess you like

Origin www.cnblogs.com/huainanhai/p/11329580.html