urain39 / stuff

Noting here.
1 stars 0 forks source link

GET请求和POST请求的长度限制 #109

Open urain39 opened 3 years ago

urain39 commented 3 years ago

GET请求中所有的数据都会被加到链接后面,所以长度受限于收发端最大链接长度限制。而POST请求则不会将数据加到链接后面,它的数据会被加到报头里。

POST / HTTP/1.1
Content-Type: multipart/form-data; boundary=---------------------------735323031399963166993862150
Content-Length: 834

-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="text1"

text default
-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="text2"

aωb
-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="file1"; filename="a.txt"
Content-Type: text/plain

Content of a.txt.

-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="file2"; filename="a.html"
Content-Type: text/html

<!DOCTYPE html><title>Content of a.html.</title>

-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="file3"; filename="binary"
Content-Type: application/octet-stream

aωb
-----------------------------735323031399963166993862150--

题外话:关于报头里多个文件分隔是否安全?这一点可以参考这个提问