如何使网络测试接受文件下载?

发布于 2024-07-18 02:19:03 字数 900 浏览 7 评论 0原文

我正在使用 Visual Studio Team Foundation Server 2008 Team Suite 为网站创建 Web 测试。 在某些页面上,响应是文件下载(通常是 PDF),我只需要测试响应是否返回正确的状态代码和内容类型,忽略正文。 当我在 Visual Studio 中运行 webtest,或使用 MSTest 运行编译的测试并加载结果时,这些请求失败,导致整个 webtest 失败。

测试结果的“Web 浏览器”选项卡包含文本:

Request failed: Unable to read data from the transport connection: The connection was closed.

“详细信息”选项卡包含异常:“

System.IO.IOException: Unable to read data from the transport connection: The connection was closed.
   at System.Net.ConnectStream.EndRead(IAsyncResult asyncResult)
   at Microsoft.VisualStudio.TestTools.WebStress.DataCaptureStream.EndRead(IAsyncResult asyncResult)
   at Microsoft.VisualStudio.TestTools.WebStress.WebTestTransaction.ReadResponse(IAsyncResult result)

响应”选项卡显示成功的响应,标头包括“HTTP/1.1 200 OK”和“Content-Type : application/pdf”,以及正文中的 PDF 内容。

如何让 webtest 接受 PDF 或其他类型的文件来满足这些请求?

I'm using Visual Studio Team Foundation Server 2008 Team Suite to create a webtest for a site. On some pages the response is a file download (usually a PDF), and I just need to test that the response comes back with the right status code and content type, ignoring the body. When I run the webtest in Visual Studio, or run the compiled test with MSTest and load the results, those requests fail, causing the entire webtest to fail.

The Web Browser tab of the test results has the text:

Request failed: Unable to read data from the transport connection: The connection was closed.

And the Details tab contains the exception:

System.IO.IOException: Unable to read data from the transport connection: The connection was closed.
   at System.Net.ConnectStream.EndRead(IAsyncResult asyncResult)
   at Microsoft.VisualStudio.TestTools.WebStress.DataCaptureStream.EndRead(IAsyncResult asyncResult)
   at Microsoft.VisualStudio.TestTools.WebStress.WebTestTransaction.ReadResponse(IAsyncResult result)

The Response tab shows a successful response, with headers including "HTTP/1.1 200 OK" and "Content-Type : application/pdf", and the PDF content in the body.

How can I make the webtest accept PDFs or other types of files for those requests?

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

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

发布评论

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

评论(2

青朷 2024-07-25 02:19:03

Visual Studio Team System 2008 SP1 中存在一个显示此类症状的错误。 尝试为其安装热修复程序。 更多详细信息请参见此处:
http://kbalertz.com/972678/successively -recorded-Visual-Studio-System-authentication-redirected-logon.aspx

There is a bug in Visual Studio Team System 2008 SP1 which shows such symptoms. Try install hot fix for it. More details here:
http://kbalertz.com/972678/successfully-recorded-Visual-Studio-System-authentication-redirected-logon.aspx

夜还是长夜 2024-07-25 02:19:03

老实说,听起来像是浏览器问题,请使用类型/未知来强制在客户端上另存为,而不是客户端的默认浏览器尝试显示它。

sounds like a browser issue to be honest, use the type/unknown to force a save as on the client instead of the client's default browser attempting to display it.

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