views:

31

answers:

1

I'm writing some code that parses HTTP requests and responses, but it may not see both sides of every conversation.

The HTTP RFC states that a HEAD request should cause exactly the same response as GET except that a message body is not sent. This seems to imply that a Content-Length header would be included.

If HTTP Pipelining is being used, I cannot see how you would reliably parse a pipelined response to a HEAD without having seen the request; the headers would not correctly indicate the length of the response, there is no Transfer-Encoding, and the connection would not necessarily be closed at the end.

Any ideas? Can anyone see any other types of response that cannot be parsed without seeing the request?

+1  A: 

I agree. It is not possible to know that the response to the request does not have an entity body, even though the ContentLength header seems to imply the opposite. All implementations should take the request method into account for this reason.

feroze