查询字符串的最大可能长度是多少? [英] What is the maximum possible length of a query string?

查看:50
本文介绍了查询字符串的最大可能长度是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否依赖浏览器?另外,不同的网络堆栈对他们可以从请求中获取多少数据有不同的限制吗?

Is it browser dependent? Also, do different web stacks have different limits on how much data they can get from the request?

推荐答案

RFC 2616(超文本传输​​协议 — HTTP/1.1)规定查询字符串的长度没有限制(第 3.2.1 节).RFC 3986(统一资源标识符 — URI)也指出没有限制,但指出由于 DNS 限制(第 2.3.3 节),主机名限制为 255 个字符.

RFC 2616 (Hypertext Transfer Protocol — HTTP/1.1) states there is no limit to the length of a query string (section 3.2.1). RFC 3986 (Uniform Resource Identifier — URI) also states there is no limit, but indicates the hostname is limited to 255 characters because of DNS limitations (section 2.3.3).

虽然规范没有规定任何最大长度,但实际限制是由网络浏览器和服务器软件强加的.不幸的是,基于研究,该研究在其原始网站上不再可用(它导致了一个看似阴暗的贷款网站),但仍然可以在 Boutell.com 的互联网档案:

While the specifications do not specify any maximum length, practical limits are imposed by web browser and server software. Based on research which is unfortunately no longer available on its original site (it leads to a shady seeming loan site) but which can still be found at Internet Archive Of Boutell.com:

Chrome
它在 64k 个字符后停止显示 URL,但可以提供超过 100k 个字符.除此之外没有进行进一步的测试.

Chrome
It stops displaying the URL after 64k characters, but can serve more than 100k characters. No further testing was done beyond that.

Firefox(浏览器)
在 65,536 个字符之后,位置栏不再显示 Windows Firefox 1.5.x 中的 URL.但是,更长的 URL 将起作用.100,000 个字符后未进行进一步测试.

Firefox (Browser)
After 65,536 characters, the location bar no longer displays the URL in Windows Firefox 1.5.x. However, longer URLs will work. No further testing was done after 100,000 characters.

Safari(浏览器)
至少 80,000 个字符将起作用.除此之外没有尝试过测试.

Safari (Browser)
At least 80,000 characters will work. Testing was not tried beyond that.

Opera(浏览器)
至少 190,000 个字符将起作用.190,000 个字符后停止测试.Opera 9 for Windows 继续显示完全可编辑,即使在 190,000 个字符的位置栏中也可复制和粘贴 URL.

Opera (Browser)
At least 190,000 characters will work. Stopped testing after 190,000 characters. Opera 9 for Windows continued to display a fully editable, copyable and pasteable URL in the location bar even at 190,000 characters.

Microsoft Internet Explorer(浏览器)
Microsoft 声明 Internet Explorer 中 URL 的最大长度为 2,083 个字符,URL 的路径部分不能超过 2,048 个字符.尝试使用比这更长的 URL 会在 Internet Explorer 中产生一个明确的错误消息.

Microsoft Internet Explorer (Browser)
Microsoft states that the maximum length of a URL in Internet Explorer is 2,083 characters, with no more than 2,048 characters in the path portion of the URL. Attempts to use URLs longer than this produced a clear error message in Internet Explorer.

Apache(服务器)
早期在 Web 浏览器中测量最大 URL 长度的尝试遇到了大约 4,000 个字符的服务器 URL 长度限制,之后 Apache 生成了413 实体太大"错误消息.错误.使用了在 Red Hat Enterprise Linux 4 中找到的当前最新的 Apache 版本.Apache 官方文档仅提及请求中单个字段的 8,192 字节限制.

Apache (Server)
Early attempts to measure the maximum URL length in web browsers bumped into a server URL length limit of approximately 4,000 characters, after which Apache produces a "413 Entity Too Large" error. The current up to date Apache build found in Red Hat Enterprise Linux 4 was used. The official Apache documentation only mentions an 8,192-byte limit on an individual field in a request.

Microsoft Internet Information Server(服务器)
默认限制为 16,384 个字符(是的,Microsoft 的 Web 服务器接受比 Microsoft 的 Web 浏览器更长的 URL).这是可配置的.

Microsoft Internet Information Server (Server)
The default limit is 16,384 characters (yes, Microsoft's web server accepts longer URLs than Microsoft's web browser). This is configurable.

Perl HTTP::Daemon(服务器)
最多 8,000 个字节将起作用.那些使用 Perl 的 HTTP::Daemon 模块构建 Web 应用程序服务器的人将遇到所有 HTTP 请求标头的总大小为 16,384 字节的限制.这不包括 POST 方法表单数据、文件上传等,但它包括 URL.实际上,当 URL 明显长于 8,000 个字符时,这会导致 413 错误.这个限制可以很容易地消除.在 Daemon.pm 中查找所有出现的 16x1024 并将它们替换为更大的值.当然,这确实会增加您遭受拒绝服务攻击的风险.

Perl HTTP::Daemon (Server)
Up to 8,000 bytes will work. Those constructing web application servers with Perl's HTTP::Daemon module will encounter a 16,384 byte limit on the combined size of all HTTP request headers. This does not include POST-method form data, file uploads, etc., but it does include the URL. In practice this resulted in a 413 error when a URL was significantly longer than 8,000 characters. This limitation can be easily removed. Look for all occurrences of 16x1024 in Daemon.pm and replace them with a larger value. Of course, this does increase your exposure to denial of service attacks.

这篇关于查询字符串的最大可能长度是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆