URL最大长度问题

URL最大长度问题

2023年6月25日发(作者:)

URL最⼤长度问题今天在测试Email Ticket的时候发现在进⾏Mark as Read/Unread操作时,请求是通过GET⽅式进⾏的。URL中列出了所有参与该操作的Ticket Id。于是,我想起GET请求是有最⼤长度限制的。遂输⼊超长⼀串Ticket Id进⾏请求,结果页⾯报错如下:HTTP Error 404.15 - Not FoundThe request filtering module is configured to deny a request where the query string is too likely causes:Request filtering is configured on the Web server to deny the request because the query string is too you can try:Verify the configuration/ver/security/requestFiltering/requestLimits@maxQueryString setting in or and More InformationThis is a security feature. Do not change this feature unless the scope of the change is fully understood. Youcan configure the IIS server to reject requests whose query string is greater than a specified value. If the request's query string is greaterthan the configured value, this error is returned. If the allowed length of the query string needs to be increased, modify theconfiguration/ver/security/requestFiltering/requestLimits@maxQueryString setting.经过⼀番搜索之后,发现IIS 7对于Query String有长度限制。默认为2048.该问题的解决办法可以通过修改configuration/ver/security/requestFiltering/requestLimits@maxQueryString setting.具体可以查看微软KB:

搜索过程中发现,各浏览器与各Web Server对URL均有长度的限制如下:在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 amaximum path length of 2,048 characters. This limit applies to both POST request and GET request you are using the GET method, you are limited to a maximum of 2,048 characters, minus the number of characters in the actual r, the POST method is not limited by the size of the URL for submitting name/value pairs. These pairs are transferred in the headerand not in the x (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 LargeThe requested URL's length exceeds the capacity limit for this /2.2.12 (Ubuntu) Server at 127.0.1.1 Port 80Apache (Server)能接受最⼤url长度为8,192个字符,但我的测试数据是8,182。Microsoft Internet Information Server(IIS)能接受最⼤url的长度为16,384个字符。通过上⾯的数据可知,为了让所有的⽤户都能正常浏览,我们的URL最好不要超过IE的最⼤长度限制(2083个字符),当然,如果URL不直接提供给⽤户,⽽是提供给程序调⽤,侧这时的长度就只受Web服务器影响了。注:可能有些朋友会想当然的认为,如果最⼤长度限制为2083字符,是不是参数差不多可以传递1000个左右的汉字。这样认为其实是不对的,对于中⽂的传递,最终会为urlencode后的编码形式进⾏传递,如果浏览器的编码为UTF8的话,⼀个汉字最终编码后的字符长度为9个字符。

发布者:admin,转转请注明出处:http://www.yc00.com/news/1687679785a30972.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信