简体   繁体   English

HTTP / 1.1是否允许通过半关闭连接来分隔请求的结束?

[英]Does HTTP/1.1 allow delimiting end of request by half-closing the connection?

RFC2616 part 4.4 specifies how the end of the message is determined in HTTP/1.1. RFC2616第4.4部分规定了如何在HTTP / 1.1中确定消息的结尾。 Item 5 in that section specifies that the server may close the connection to indicate the response is finished. 该部分中的第5项指定服务器可以关闭连接以指示响应已完成。

It also goes on to say that delimiting the request like this is impossible. 它还继续说,像这样划定请求是不可能的。 However, TCP allows the client to close its end and go on to receive a response. 但是,TCP允许客户端关闭其结束并继续接收响应。 I've even tested it; 我甚至测试过它; it works. 有用。

Questions: 问题:

  • Why does a standard dated 1999 say this is impossible when it's actually possible? 为什么1999年的标准说这在实际可能的情况下是不可能的? TCP was well established by then, and had supported half-close for a long time by then (possibly all the way since 1974?). 那时TCP已经很好地建立起来了,并且到那时已经支持了半封闭(可能是自1974年以来的所有方式?)。

  • Is it a violation of the protocol for a client to half-close the connection to indicate end-of-request? 是否违反了协议,客户端半关闭连接以指示请求结束?

Please disregard whether this is a good idea: I am aware of how you sometimes can't quite tell whether the connection was closed on purpose or just broke, and how it makes a lot more sense to keep the connection open to reuse it later. 请忽略这是否是一个好主意:我知道你有时无法确定连接是故意关闭还是刚刚破坏,以及如何保持连接打开以便以后重用它更有意义。

It doesn't say a half-close is impossible. 它并没有说半封闭是不可能的。 It just says 'closing the connection cannot be used to indicate the end of a request body', which is true. 它只是说'关闭连接不能用于指示请求体的结束',这是真的。 It simply doesn't consider the possibility of a half-close one way or the other. 它根本不考虑半途关闭的可能性。 As it isn't mentioned in the RFC, I would say using it would be a violation of the protocol, and you should have no grounds for expecting servers to react accordingly: for example, a server would be entitled to just forget the request and close the connection on receiving the FIN. 因为在RFC中没有提到,我会说使用它会违反协议,你应该没有理由期望服务器做出相应的反应:例如,服务器有权忘记请求和接收FIN时关闭连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM