About the difference between the post and get

First, get and post are not fundamentally different, just HTTP protocol request of two ways, are used in the same transport protocol on transport is no different.

   

             

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Difference in 1.get and post messages

    GET and POST requests only HTTP protocol of two ways, the HTTP protocol is TCP / IP based application layer protocol, regardless of GET or POST, with a transport layer protocol are the same, so the transmission, there is no difference.

    The packet format, with no parameters, the biggest difference is the first line of the method name

    POST method request packet is such that a first row POST /uri HTTP/1.1 \r\n

    GET method request packet is such that a first row GET /uri HTTP/1.1 \r\n

    The difference between arguments Times article is a GET method parameters should be placed in the url, POST method parameters should be placed in the body  

    get method simple version of the message:

 GET /index.php?name=xiaoming.c&age=3 HTTP/1.1 Host: localhost

     post method simple version of the message:

 POST /index.php HTTP/1.1  Host: localhost  Content-Type: application/x-www-form-urlencode
name=qiming.c&age=22

Differences 2. GET and POST methods Security

       According to explain most of the online article, POST than GET security, because the data is not visible in the address bar

       However, from the point of view of transmission, they are not safe, because HTTP is transmitted in the clear over the network, as long as catch packets on the network node, you can get a complete data packet.

       To secure transmission, only encryption is HTTPS.

 

3. GET method has limits ? Up to 1024kb? 

     url parameter data size of the GET method to submit no limit

      HTTP protocol does not limit the length of Body and URL, the URL of the restrictions are mostly the reason the browser and the server.

      The reason is that the browser because the browser manufacturers set, because the server is processing a long URL to consume more resources, for performance and security (to prevent malicious attacks and Long URL) to consider, give URL length restrictions.

 

 

4. POST method of generating two packets?

     Some mentioned viewpoint, post will send separate header and body, the first transmission header, the status code returned from the server 100 then transmits body.

     HTTP 协议中没有明确说明 POST 会产生两个 TCP 数据包,而且实际测试(Chrome)发现,header 和 body 不会分开发送。

     所以,header 和 body 分开发送是部分浏览器或框架的请求方法,不属于 post 必然行为。

 

      

 

5. “get常用于获取数据,post用于提交数据”

    虽然get的确常被用于获取数据,但post也可以在一些UI框架被用于取回数据    

    get和post用途也是因地制宜,要根据实际情况来决定用哪个方法。

 

 

  

  





 

Guess you like

Origin www.cnblogs.com/mhcll/p/11391522.html