Request method get and post

get the post of the differences:

  • GET - request data from the specified resource.

  • POST - submission of data to be processed to the specified resource

GET POST
Back / Refresh harmless Data will be resubmitted
Bookmark Can be bookmarked Not bookmarked
Cache Be cached Can not cache
Encoding type application More use of multiple encoded as a binary data
history Parameters will remain in history Not saved in the historical data
Restrictions on the length of Up to 2048 Unlimited
Restrictions on data type ASCII There is no limit, it may be a binary data
safety Poor security, sensitive data, passwords, do not use the High security
Visibility Data visible to everyone in the URL Data is not limited to the URL

common problem:

GET方法参数是固定的么?

    在约定中我们的参数是写在?后面,用&分割,解析报文的过程是通过获取TCP数据,用正则表达式等工具获取Header和Body

GET的长度限制:

    浏览器地址栏输入的参数是有限的,Http协议中没有长度限制,对URl的长度限制通常为浏览器或者服务器的原因

POST比GET安全:

    因为POST数据在地址栏中不可见, 但是安全只是相对的,因为HTTP在网络中是明文传输的,要想加密,就必须要用HTTPS

POST会产生2个TCP数据包?

    POST会将Header和Body分开发送,但是HTTP协议中没有明确会产生2个数据包,而且实际测试的时候也不会分开发送,所以分开发送只是部分浏览器和框架的请求方法,不属于POST的必然行为。

The essential difference:

    GET和POST本质上两者没有任何区别。他们都是HTTP协议中的请求方法。底层实现都是基于TCP/IP协议。上述的所谓区别,只是浏览器厂家根据约定,做得限制而已

    HTTP请求,最初设定了八种方法。这八种方法本质上没有任何区别。只是让请求,更加有语义而已。

OPTIONS 返回服务器所支持的请求方法
GET 向服务器获取指定资源
HEAD 与GET一致,只不过响应体不返回,只返回响应头
POST 向服务器提交数据,数据放在请求体里
PUT 与POST相似,只是具有幂等特性,一般用于更新
DELETE 删除服务器指定资源
TRACE 回显服务器端收到的请求,测试的时候会用到这个

Guess you like

Origin www.cnblogs.com/shaozheng/p/12088323.html