在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。
引用:
https://stackoverflow.com/questions/2659952/maximum-length-of-http-get-request