是否有实用的 HTTP 标头长度限制? [英] Is there a practical HTTP Header length limit?

查看:30
本文介绍了是否有实用的 HTTP 标头长度限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Web 应用程序,它使用 XmlHttpRequest 对象添加上下文信息="http://www.w3.org/TR/XMLHttpRequest/#setrequestheader" rel="noreferrer">setRequestHeader API.我正在使用自定义标头名称(例如 X-Foo)和 JSON 结构化值.它不是 URL QueryString 或 POST 正文的一部分,因为它是有关请求的元信息.

I have a web application that adds contextual information to XmlHttpRequest objects using the setRequestHeader API. I am using a custom header name (e.g. X-Foo) and a JSON structured value. It isn't part of the URL QueryString or POST body because it is meta information about the request.

标题值是否有实际大小限制?如果我的 JSON 被截断,它将变得无法解析.我最关心的是 Apache 2、Tomcat 6 和 IIS 7 中的限制.我在 Google 上搜索了 http 标头长度限制,但许多结果似乎已经过时.用户代理字符串可以有多大? 但没有我想要的那么具体.

Is there a practical size limit to the header value? If my JSON gets truncated, it becomes unparseable. I am most concerned with limits in Apache 2, Tomcat 6 and IIS 7. I did a Google search for http header length limit, but many of the results seem dated. There are some relevant comments in How big can a user agent string get? but not as specific as I would like.

我刚刚遇到了这个类似的问题 - http 标头值的最大值?

I just ran across this similar question - Maximum on http header values?

推荐答案

是的,但限制是可配置的并且取决于平台.例如,Tomcat 的默认限制为 8K.我相信 IIS 6,不确定 IIS 7,有 16K 的限制.我在对几个网站使用集成的 Windows 身份验证时遇到了这个问题.原来我的安全令牌在编码到标头时太大了.幸运的是,这些是可配置的.可以在 http://support.microsoft.com/kb/820129 上找到 IIS 的注册表设置.我相信要更改的关键设置是 MaxFieldLength(每个标头大小)和 MaxRequestBytes(请求的总大小).

Yes, but the limits are configurable and dependent on platform. For example, Tomcat has a default limit of 8K. I believe that IIS 6, not sure about IIS 7, has a limit of 16K. I ran into this when using integrated windows authentication for several web sites. Turns out my security token was too large when encoded into the header. Fortunately, these are configurable. Registry settings for IIS can be found at http://support.microsoft.com/kb/820129. I believe the key settings to change are MaxFieldLength (per header size) and MaxRequestBytes (total size of request).

这篇关于是否有实用的 HTTP 标头长度限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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