HTTP header Get 响应没有内容长度给出 502 bad gateway

发布于 2024-12-09 09:38:14 字数 143 浏览 1 评论 0原文

要创建彗星连接(挂起获取),我没有在 HTTP 标头中指定内容长度。这在我的系统上有效,但会从研究所 LAN 的另一台机器请求,它为请求提供 502 Bad Gateway。

如果我提到内容长度,我会得到响应,但连接会关闭,这是我不想要的。有什么替代方案?

To create a comet connection (hanging get) i am not specifying the content-length in HTTP Header. This works on my system but will requested from another machine of institute LAN, it gives 502 Bad Gateway for the request.

If i mention content-length, i get the response but the connection gets closed, which i dont want. What can be the alternatives to this?

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

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

发布评论

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

评论(1

陌路终见情 2024-12-16 09:38:14

遵循 HTTP/1.1 规范来保持连接。在回复中返回HTTP/1.1。如果查询是 HTTP/1.1,则默认保持连接打开。如果查询不是,则默认关闭它。如果您收到 Connection: close 标头,请在发送响应后关闭连接。如果您收到 Connection: keep-alive 标头,请保持连接打开,即使这不是协议默认值。

如果您不想遵循 HTTP/1.1,那么无论如何您都可以获得连接持久性。如果您通过上述规则成功建立持久性,则始终包含 Connection: Keep-Alive 标头。如果您无法支持持久连接(即使客户端请求了一个连接),请发送 Connection: Close 标头。

基本上,遵循 HTTP 规范。如果您知道内容长度,则应始终发送Content-Length标头。如果客户端可以支持持久连接,请使用持久协商规则来建立持久连接。

Follow the HTTP/1.1 specification for connection persistence. Return HTTP/1.1 in the reply. If the query was HTTP/1.1, default to keeping the connection open. If the query wasn't, default to closing it. If you get a Connection: close header, close the connection after sending the response. If you get a Connection: keep-alive header, keep the connection open even if that wasn't the protocol default.

If you don't want to follow HTTP/1.1, you can probably get connection persistence anyway. Just always include a Connection: Keep-Alive header if you successfully establish persistence through the rules above. Send a Connection: Close header if you cannot support a persistent connection even though the client requested one.

Basically, follow the HTTP specification. If you know the content length, you should always send a Content-Length header. Use the persistence negotiation rules to establish a persistent connection if the client can support one.

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