Maximum on http header values?

前端 未结 5 751
-上瘾入骨i
-上瘾入骨i 2020-11-22 09:45

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 heade

5条回答
  •  爱一瞬间的悲伤
    2020-11-22 10:14

    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).

    • Apache 2.0, 2.2: 8K
    • nginx: 4K - 8K
    • IIS: varies by version, 8K - 16K
    • Tomcat: varies by version, 8K - 48K (?!)

    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:

    #include 
    #include 
    
    int main() {
        int pageSize = getpagesize();
        printf("Page size on your system = %i bytes\n", pageSize);
        return 0;
    }
    

    Compile with gcc -o pagesize pagesize.c then run ./pagesize. My ubuntu server from Linode dutifully informs me the answer is 4k.

提交回复
热议问题