GET请求的请求参数最大长度

在HTTP规范RFC-2616中有这样一段描述:

The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET- based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15).

Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths.

从以上内容中可以看出,HTTP RFC规范中并没有规定GET请求的URI长度,只是说明如果server无法处理太长的URI,可以通过返回414状态码。

规范中虽然未对GET请求的长度做出明确的规定,但是在主流的用户代理浏览器和应用服务器中对GET请求却做出限制或者相关的可配置:

  • Chrome(谷歌)的url长度限制超过8182个字符返回本文开头时列出的错误。

  • IE浏览器(Microsoft Internet Explorer) 对url长度限制是2083(2K+53),超过这个限制,则自动截断(若是form提交则提交按钮不起作用)。

  • Apache能接受url长度限制为8192字符

  • tomcat中通过较多的Connector参数控制url长度限制:
    maxParameterCount:GET和POST请求参数个数,默认是10000
    maxPostSize:POST请求数据最大值

  • nginx可以通过修改配置来改变url请求串的url长度限制:
    client_header_buffer_size 默认值:1k
    large_client_header_buffers默认值:4 8k

大多数浏览器的限制在2k-8k之间,更老的版本浏览器甚至只支持255 bytes。

posted on   WHOISWAV  阅读(2463)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示