Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. Item 5 in that section specifies that the server may close the connection to indicate the response is finished.

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. I've even tested it; it works.

Questions:

  • Why does a standard dated 1999 say this is impossible when it's actually possible? TCP was well established by then, and had supported half-close for a long time by then (possibly all the way since 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.

like image 424
Roman Starkov Avatar asked Dec 28 '12 12:12

Roman Starkov


1 Answers

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.

like image 130
user207421 Avatar answered Sep 16 '22 11:09

user207421