Is there an accepted maximum allowed size for HTTP headers? If so, what is it? If not, is this something that's server specific or is the accepted standard to allow headers of any size?
相关问题
- Angular RxJS mergeMap types
- Google Apps Script: testing doPost() with cURL
- How to instantiate Http service in main.ts manuall
- C#使用http访问网络,有办法用指定网卡访问网络嘛?
- PHP Empty $_POST
相关文章
- C#使用http访问网络,有办法用指定网卡访问网络嘛?
- Is there a size limit for HTTP response headers on
- Is a unicode user agent legal inside an HTTP heade
- git: retry if http request failed
- What is the definition of HTTP_X_PURPOSE?
- Flutter - http.get fails on macos build target: Co
- Why does Google Chrome NOT use cached pages when I
- C# HttpClient.SendAsync always returns 404 but URL
As vartec says above, the HTTP spec does not define a limit, however many servers do by default. This means, practically speaking, the lower limit is 8K. For most servers, this limit applies to the sum of the request line and ALL header fields (so keep your cookies short).
It's worth noting that nginx uses the system page size by default, which is 4K on most systems. You can check with this tiny program:
pagesize.c:
Compile with
gcc -o pagesize pagesize.c
then run./pagesize
. My ubuntu server from Linode dutifully informs me the answer is 4k.HTTP Header values are restricted by server implementations. Http specification doesn't restrict header size.
Most servers will return
413 Entity Too Large
or appropriate 4xx error when this happens.Uncapped HTTP header size keeps the server exposed to attacks and can bring down its capacity to serve organic traffic.
Source
I also found that in some cases the reason for 502/400 in case of many headers could be because of a large number of headers without regard to size. from the docs
https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#3.2-tune.http.maxhdr
No, HTTP does not define any limit. However most web servers do limit size of headers they accept. For example in Apache default limit is 8KB, in IIS it's 16K. Server will return
413 Entity Too Large
error if headers size exceeds that limit.Related question: How big can a user agent string get?