1. HTTP 協議 未規定 GET 和POST的長度限制
  2. GET的最大長度顯示是因為 瀏覽器和 web伺服器限制了 URI的長度
  3. 不同的瀏覽器和WEB伺服器,限制的最大長度不一樣
  4. 要支援IE,則最大長度為2083byte,若只支援Chrome,則最大長度 8182byte


大家都知道http 中 存在 GET 和 POST 這兩種最常用的請求方式。(PUT,DELETE不在本文討論範圍之內)

誤解:HTTP 協議下的 Get 請求引數長度是有大小限制的,最大不能超過XX,而 Post 是無限制的。

1、首先即使有長度限制,也是限制的是整個 URI 長度而不僅僅是你的引數值資料長度

2、HTTP 協議從未規定 GET/POST 的請求長度限制是多少。

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.

3、所謂的請求長度限制是由瀏覽器web 伺服器決定和設定的,各種瀏覽器和 web 伺服器的設定 均不一樣,這依賴於各個瀏覽器廠家的規定或者可以根據 web 伺服器的處理能力來設定。

The limit is in MSIE and Safari about 2KB, in Opera about 4KB and in Firefox about 8KB, (255 bytes if we count very old browsers) . We may thus assume that 8KB is the maximum possible length and that 2KB is a more affordable length to rely on at the server side and that 255 bytes is the safest length to assume that the entire URL will come in. If the limit is exceeded in either the browser or the server, most will just truncate the characters outside the limit without any warning. Some servers however may send a HTTP 414 error. If you need to send large data, then better use POST instead of GET. Its limit is much higher, but more dependent on the server used than the client. Usually up to around 2GB is allowed by the average webserver. This is also configureable somewhere in the server settings. The average server will display a server-specific error/exception when the POST limit is exceeded, usually as HTTP 500 error.

IE 和 Safari 瀏覽器 限制 2k Opera 限制4k Firefox 限制 8k(非常老的版本 256byte)


HTTP 1.1 defines Status Code 414 Request-URI Too Long for the cases where a server-defined limit is reached. You can see further details on RFC 2616. For the case of client-defined limits, there is no sense on the server returning something, because the server won't receive the request at all.

詳細可以看 RFC2616

The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret. This rare condition is only likely to occur when a client has improperly converted a POST request to a GET request with long query information, when the client has descended into a URI "black hole" of redirection (e.g., a redirected URI prefix that points to a suffix of itself), or when the server is under attack by a client attempting to exploit security holes present in some servers using fixed-length buffers for reading or manipulating the Request-URI.


** 以下內容摘自《GET請求中URL的最大長度限制總結》, 文章內容是 2016年9月,相對比較符合當前的最新現狀。 **




IE瀏覽器(Microsoft Internet Explorer) 對url長度限制是2083(2K+53),超過這個限制,則自動截斷(若是form提交則提交按鈕不起作用)。


firefox(火狐瀏覽器)的url長度限制為 65 536字元,但實際上有效的URL最大長度不少於100,000個字元。




Safari的url長度限制至少為 80 000 字元。


Opera 瀏覽器的url長度限制為190 000 字元。Opera 9 位址列中輸入190 000字元時依然能正常編輯。



Apache能接受url長度限制為8 192 字元


Microsoft Internet Information Server(IIS)能接受url長度限制為16 384個字元。 這個是可以通過修改的(IIS7) configuration/system.webServer/security/requestFiltering/[email protected]<requestLimits maxQueryString="length"/>

3、Perl HTTP::Daemon

Perl HTTP::Daemon 至少可以接受url長度限制為8000字元。Perl HTTP::Daemon中限制HTTP request headers的總長度不超過16 384位元組(不包括post,file uploads等)。但當url超過8000字元時會返回413錯誤。 這個限制可以被修改,在Daemon.pm查詢16×1024並更改成更大的值。



client_header_buffer_size 預設值:client_header_buffer_size 1k

large_client_header_buffers預設值 :large_client_header_buffers 4 4k/8k

由於jsonp跨域請求只能通過get請求,url長度根據瀏覽器及伺服器的不同而有不同限制。 若要支援IE的話,url長度限制為2083字元,若是中文字元的話只有2083/9=231個字元。 若是Chrome瀏覽器支援的最大中文字元只有8182/9=909個。


. 作者:izhongxia 連結: 來源:簡書 著作權歸作者所有。商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。