今天在測試Email Ticket的時候發如今進行Mark as Read/Unread操做時,請求是經過GET方式進行的。URL中列出了全部參與該操做的Ticket Id。因而,我想起GET請求是有最大長度限制的。遂輸入超長一串Ticket Id進行請求,結果頁面報錯以下:web
The request filtering module is configured to deny a request where the query string is too long.chrome
Most likely causes:apache
Things you can try:ubuntu
Links and More InformationThis is a security feature. Do not change this feature unless the scope of the change is fully understood. You can configure the IIS server to reject requests whose query string is greater than a specified value. If the request's query string is greater than the configured value, this error is returned. If the allowed length of the query string needs to be increased, modify the configuration/system.webServer/security/requestFiltering/requestLimits@maxQueryString setting.瀏覽器
通過一番搜索以後,發現IIS 7對於Query String有長度限制。默認爲2048.app
該問題的解決辦法能夠經過修改configuration/system.webServer/security/requestFiltering/requestLimits@maxQueryString setting.less
<requestLimits maxQueryString="length" />
具體能夠查看微軟KB: Error message when you visit a Web site that is hosted on a server that is running IIS 7.0: "HTTP Error 404.15 – Not Found"測試
搜索過程當中發現,各瀏覽器與各Web Server對URL均有長度的限制以下:this
在http協議中,其實並無對url長度做出限制,每每url的最大長度和用戶瀏覽器和Web服務器有關,不同的瀏覽器,能接受的最大長度每每是不同的,固然,不同的Web服務器可以處理的最大長度的URL的能力也是不同的。
下面就是對各類瀏覽器和服務器的最大處理能力作一些說明.
Microsoft Internet Explorer (Browser)
IE瀏覽器對URL的最大限制爲2083個字符,若是超過這個數字,提交按鈕沒有任何反應。在個人測試中,這個數字獲得驗證。
微軟官方也有說明:
Microsoft Internet Explorer has a maximum uniform resource locator (URL) length of 2,083 characters. Internet Explorer also has a maximum path length of 2,048 characters. This limit applies to both POST request and GET request URLs.
If you are using the GET method, you are limited to a maximum of 2,048 characters, minus the number of characters in the actual path.
However, the POST method is not limited by the size of the URL for submitting name/value pairs. These pairs are transferred in the header and not in the URL.
Firefox (Browser)
對於Firefox瀏覽器URL的長度限制爲65,536個字符,但當我測試時,最大隻能處理8182個字符,這是由於url的長度除了瀏覽器限制外,還會受Web服務器的限制,而我本機使用的是ubuntu apache服務器,最大處理能力爲8192個字符(相差10個字符,不知道是什麼緣由),一旦超過這個長度,服務器就返回以下錯誤信息。
Safari (Browser)
URL最大長度限制爲 80,000個字符。
Opera (Browser)
URL最大長度限制爲190,000個字符。
Google (chrome)
url長度一旦超過8182個字符時,出現以下服務器錯誤:
寫道
Request-URI Too Large
The requested URL's length exceeds the capacity limit for this server.
Apache/2.2.12 (Ubuntu) Server at 127.0.1.1 Port 80
Apache (Server)
能接受最大url長度爲8,192個字符,但個人測試數據是8,182。
Microsoft Internet Information Server(IIS)
能接受最大url的長度爲16,384個字符。
經過上面的數據可知,爲了讓全部的用戶都能正常瀏覽,咱們的URL最好不要超過IE的最大長度限制(2083個字符),固然,若是URL不直接提供給用戶,而是提供給程序調用,側這時的長度就只受Web服務器影響了。
注:可能有些朋友會想固然的認爲,若是最大長度限制爲2083字符,是否是參數差很少能夠傳遞1000個左右的漢字。這樣認爲實際上是不對的,對於中文的傳遞,最終會爲urlencode後的編碼形式進行傳遞,若是瀏覽器的編碼爲UTF8的話,一個漢字最終編碼後的字符長度爲9個字符。