团队测试:负载失败。请求失败:服务器违反了协议。部分 = 响应标头详细信息 = CR 后必须跟 LF

发布于 2024-10-14 15:36:31 字数 1007 浏览 2 评论 0原文

QA 部门的人员使用 Visual Studio Team Test (2008 IIRC) 对我们的 Web 应用程序运行负载测试。

最新的一组测试在几个页面上都失败了。报告的错误是

请求失败:服务器违反了协议。 Section=ResponseHeader Detail=CR 后面必须跟 LF

使用 google 搜索此内容会产生相当多的结果。该错误消息似乎是从 .Net 框架 WebRequest 类生成的(即,它不是 Visual Studio 特定的消息)。最有用的结果是 这个,详细说明了我的确切问题以及如何抑制错误。

但当然,我想首先弄清楚为什么会出现这个错误。以下是更多事实: -

  • 当针对旧版本的 Web 应用程序运行测试时,从来不会发生此错误。网络应用程序。在这两种情况下,主机操作系统和 Web 服务器(Win 2003 和 IIS 6)是相同的。
  • 并非所有页面都会生成此错误 - 只有部分页面会生成此错误。
  • 这些页面的唯一重大变化(我能想到的)是它们现在使用了一些 AJAX,而之前它们没有使用 (IIRC)。

为了缩小问题范围,我创建了可以复制问题的最简单的页面。幸运的是,这并不太难。然后,我使用 Fiddler 检查了标头中的字节,但找不到 CR (0x0D) 后面没有跟随 LF (0x0A) 的情况。

原始 HTTP 响应(通过响应保存字节从 Fiddler 存储 - 因此在保存过程中不应更改其编码)是/原始输出。 txt?psid=1" rel="nofollow" title="response file">此处为文本 如果您不相信我!

所以现在我认为所谓的错误可能是误报。还有其他人有这方面的经验/可以帮助阐明吗?

The folk in the QA department use visual studio team test (2008 IIRC) to run load tests against our web application.

The latest set of tests have failed on several pages. The error reported is

Request failed: The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF

Searching for this using google yields quite a few results. it would appear that this error message is generated from the .Net framework WebRequest class (i.e. it is not a visual studio specific message). The most useful result is this one, which details my exact problem and how to suppress the error.

But of course, I want to get to the bottom of why this error occurs in the first place. Here are some more facts: -

  • This error never used to occur when the tests were run against an older version of the web app. The web app. host OS and web server (Win 2003 and IIS 6) are identical in both cases.
  • Not all the pages generate this error - only some.
  • The only significant change to these pages (that I can think of) is that they now use some AJAX whereas before they did not (IIRC)

In order to narrow down the problem, I created the simplest page that I could to replicate the problem. Luckily, that was not too hard. I then inspected the bytes in the header using Fiddler but I could not find an occurrence of a CR (0x0D) that was not followed by a LF (0x0A).

The raw HTTP response (as stored from Fiddler by response saving bytes - so its encoding should not have been altered during the save) is here as text if you don't believe me!

So now I am left thinking that the supposed error might be a false alarm. Does anyone else have experience of this/can help shed light?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

追风人 2024-10-21 15:36:31

这绝对不是误报 - 在尝试与 Facebook API 通信时,我的应用程序中经常遇到此错误。

我刚刚偶然发现了 Steven Cheng 的回复 - http://www.velocityreviews.com/forums/t302174-why-do-i-get-the-server-comfilled-a-protocol-violation。 html - 让我引用他的话:

根据您的描述,您正在使用
要发送的 HttpWebRequest 组件
对某些外部网络的一些 http 请求
ASP.NET Web 中的资源
应用。然而,你却始终
得到“服务器提交了
违反协议。
部分=ResponseStatusLine”错误
除非您设置以下部分
在 web.config 文件中:

<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>

您想知道这种行为的原因,对吗?

对于这个问题,我已经做了一些
对此进行研究并发现
问题实际上是由
关键的http标头
解析/验证
HttpWebRequest 组件。根据
Http 规范 (http1.1),
HTTP 标头键应特别指定
他们的名字中不包含任何空格。
然而,一些网络服务器并不完全
尊重他们应该遵守的标准。
在 Dotnet 上运行的应用程序
框架并大量使用http
请求通常使用
httpWebRequest 类,其中
封装了面向网络的一切
开发者可能梦想的。与所有的
最近与安全相关的问题,
“httpWebRequest”类提供了
自我保护机制预防
它接受 HTTP 答案,但不接受
完全符合规格。

常见情况是其中有空格
“内容长度”标头键。这
服务器实际上返回一个“内容
length”键,假设没有空格
被允许,被视为
攻击向量(HTTP 响应分割
攻击),从而触发“HTTP
协议违规错误”异常。

如果现在有帮助,将尝试并稍后发布结果

This is definitely not a false alarm - I've been getting this error in my app a lot while trying to communicate with Facebook API.

I've just stumbled upon this response from Steven Cheng - http://www.velocityreviews.com/forums/t302174-why-do-i-get-the-server-committed-a-protocol-violation.html - and let me quote him:

From your description, you're using
the HttpWebRequest component to send
some http request to some external web
resource in your ASP.NET web
application. However, you're always
getting the "The server committed a
protocol violation.
Section=ResponseStatusLine" error
unless you set the following section
in the web.config file:

<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>

And you're wondering the cause of this behavior, correct?

As for this issue, I've performed some
research on this and found that the
problem is actually caused by the
critical http header
parsing/validating of the
HttpWebRequest component. According to
the Http Specification(http1.1), the
HTTP header keys shoud specifically
not include any spaces in their names.
However, some web servers do not fully
respect standards they're meant to.
Applications running on the Dotnet
framework and making heavy use of http
requests usually use the
httpWebRequest class, which
encapsulates everything a web oriented
developer could dream of. With all the
recently issues related to security,
the "httpWebRequest" class provides a
self protection mechanism preventing
it to accept HTTP answers which not
fully qualify to the specifications.

The common case is having a space in
the "content-length" header key. The
server actually returns a "content
length" key, which, assuming no spaces
are allowed, is considered as an
attack vector (HTTP response split
attack), thus, triggering a "HTTP
protocol violation error" exception.

Will try if this helps right now and post results later

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文