2

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?

4

1 回答 1

1

据我所知,这就是我们需要了解的关于半封闭连接的全部内容。

服务器只有在检测到客户端关闭连接时才会关闭连接(它可以在服务器即将写入套接字时关闭)或在请求结束时,如果它不支持connection: keep-alive.

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

但是客户端实现不是问题。您应该担心服务器实施,因为这些意外断开连接会遭受很多痛苦。

编辑

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

传输控制协议 - 功能规范

传输控制协议

于 2011-03-25T17:30:59.810 回答