在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