符合HTTP 1.1 服务端与客户端连接半关闭

发布于 2024-10-25 22:13:26 字数 395 浏览 5 评论 0原文

我观察到 HTTP 1.1 服务器实现,一旦检测到其传出通道的客户端连接关闭(或者更确切地说,在发送正确的 http 响应之前或之后),它就会终止客户端连接。这是符合 HTTP 1.1 的实现吗?

RFC 2616 第 8.1.4 节似乎表明这是正确的行为:

当客户端或服务器希望超时时,它应该发出一个优雅的 关闭运输连接。客户端和服务器都应该 不断观察交通工具的另一侧是否靠近,并且 适当回应。

...

服务器不应该在传输响应的过程中关闭连接,除非怀疑网络或客户端出现故障。

我的解释正确吗?是否有关于 HTTP 1.1 上下文中的半封闭连接处理的更明确的参考?

I've observed a HTTP 1.1 Server implementation, which terminates a client connection as soon as it detects a client-side connection shutdown of its outgoing channel (or rather, either before or after sending a proper http response). Is this a conforming HTTP 1.1 implementation?

RFC 2616 Section 8.1.4 seems to suggest this is to be the proper behaviour:

When a client or server wishes to time-out it SHOULD issue a graceful
close on the transport connection. Clients and servers SHOULD both
constantly watch for the other side of the transport close, and
respond to it as appropriate.

...

Servers SHOULD NOT close a connection in the middle of transmitting a response, unless a network or client failure is suspected.

Am I interpreting it right? Is there a more explicit reference about half-closed connection handling in the context of HTTP 1.1?

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

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

发布评论

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

评论(1

嗳卜坏 2024-11-01 22:13:27

据我所知,这就是我们需要了解的有关半封闭连接的全部信息。

只有当服务器检测到客户端关闭了连接(服务器即将写入套接字时)或在请求结束时(如果不支持连接:keep-),服务器才会关闭连接。还活着。

客户端可以随时断开连接,但它应该告诉服务器为什么断开连接(time_out、请求取消)。但编写套接字组件的人不太使用它。他们只是在需要强制超时时关闭套接字。

但客户端实现不是问题。您应该担心服务器的实现,因为这些意外的断开连接会带来很多麻烦。

编辑

也许这些链接可以帮助您。

传输控制协议 - 功能规范

< a href="http://www.netfor2.com/rfc793.txt" rel="nofollow">传输控制协议

As far as i know, thats is all we need to know about Half-closed connections.

The server will only close the connection if it detects that the client closed it (it can ben when the server is about to write to the socket) or at the end of the request, if it does not support connection: keep-alive.

The client can disconnect any time, but it should tell the server why is it disconnecting (time_out, request cancel). But it is not very used by those who write sockets components. They just close the socket when they need to force a time_out.

But the client implementation is not the problem. You should worry about server implementation since suffer a lot with those unexpected disconnects.

EDIT

Maybe those links can help you.

Transmission Control Protocol - Functional Specification

TRANSMISSION CONTROL PROTOCOL

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