当前位置:网站首页>What is the difference between get and post? After reading it, you won't be confused and forced, and you won't have to fight with your friends anymore

What is the difference between get and post? After reading it, you won't be confused and forced, and you won't have to fight with your friends anymore

2022-06-24 16:21:00 PHP Development Engineer

I've been sorting out about http The contents of the agreement , I suddenly thought of an interesting and common question .

Believe a lot of little friends , See a lot of big guys' articles on the Internet , Some articles talk about GET and POST There are many differences , Some articles say there is no difference between them ,(??? Question mark face ) Is there any difference ~~~~~

Actually , Is there any difference , It depends on the perspective of this question , from 2 Analyze from different angles , You can understand , What the hell are they talking about

1、 There is no difference in the nature of the agreement ( Man is a carbon based organism , So there is no difference between humans ):

from HTTP Agreement to see ,GET and POST Essentially , All are TCP link , No big difference .GET and POST You can do the same thing . to GET add request body, to POST close url Parameters , Technically, it works perfectly . 

2、 The implementation of the specification is different ( Man is also a unique individual , Individuals have their own characteristics , Have their own responsibilities ):

On the procedure , In terms of agreement , One of our common words is : standard .

Including our development , If everyone doesn't follow the rules , I love to write my own set , The result is very bad , So from Application specification On , It shows GET and POST The difference between , And there must be a difference !!

therefore , I tend to answer this question in terms of the implementation specification , There's a difference , Because this is in line with our practical use to solve problems , More practical .

Let's take a look at the differences listed below !

  • GET It is harmless when the browser is backout , and POST The request will be submitted again .
  • GET Produced URL The address can be Bookmark, and POST Can not be .
  • GET The request will be initiated by the browser cache, and POST Can't , Unless manually set .
  • GET Request can only proceed url code , and POST Supports a variety of coding methods .
  • GET The request parameters are fully preserved in the browser history , and POST The parameters in are not retained .
  • GET Request in URL There is a length limit on the parameters passed in , and POST It has a .
  • The data type for the parameter ,GET We only accept ASCII character , and POST There is no limit to .
  • GET Than POST It's not safe , Because the parameters are directly exposed to URL On , So it can't be used to convey sensitive information .
  • GET Parameters through URL Pass on ,POST Put it in Request body in .

( The answers to this standard are from w3schools)

in addition :

about GET Method request , The browser will http header and data Send along , Server response 200( Return the data );

And for POST, Browser sends first header, Server response 100 continue, The browser sends data, Server response 200 ok( Return the data ).

That's why , To solve problems, we should face reality .

原网站

版权声明
本文为[PHP Development Engineer ]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/04/20210427190251899q.html