如何测试客户端可以保持 HTTPS 连接打开多长时间?

发布于 2024-12-13 07:11:49 字数 181 浏览 3 评论 0原文

我正在针对一个 API 进行开发,其文档表明客户端代码必须能够保持 HTTPS 连接打开长达 15 秒

我希望能够以编程方式确认此标准,最好通过在每个构建上运行的集成测试并在通过之前保持连接打开 15 秒。 (除非 C# WebRequests 在某个地方保证它们能够保持连接打开那么长时间)

有没有办法做到这一点?

I am developing against an API whose documentation says that the client code must be able to hold an HTTPS connection open for up to 15 seconds

I would like to be able to confirm this criterion programatically, preferably by having an integration test that runs on every build and holds the connection open for 15sec before passing. (Unless C# WebRequests guarantee somewhere that they will be able to hold the connection open for that long)

Is there a way to do this?

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

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

发布评论

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

评论(1

生生不灭 2024-12-20 07:11:49

这是一个两方面的事情;服务器必须支持它,并且客户端可能需要设置某种 KeepAlive 标志。 参见此处。

该示例将 KeepAlive 设置为 false ;您希望将其设置为 true。

摘自 MSDN:

使用 HTTP/1.1 时,Keep-Alive 默认处于启用状态。将 KeepAlive 设置为
false 可能会导致向服务器发送 Connection: Close 标头。

This a 2 way thing; the server has to support it and the client probably needs to set some sort of KeepAlive flag. See here.

That example sets KeepAlive to false; you'd want it set to true.

Excerpt from MSDN:

When using HTTP/1.1, Keep-Alive is on by default. Setting KeepAlive to
false may result in sending a Connection: Close header to the server.

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