Fix waiting for response body on HTTP HEAD requests with Content-Length set#334
Conversation
…ardless of content-length
|
Hey @nniclausse. Could you take a quick look at this? It took me a while to figure out what was going on here but I think the solution now is okay. But since this looks like it was so fundamentally broken, I'm a bit irritated and want to make sure I'm not overlooking something obvious here :) |
|
Sorry for pining again, but could you maybe take a quick look, @nniclausse? I've tested this quite a bit, but as I already said, this is just so strange because this was broken basically forever... |
nniclausse
left a comment
There was a problem hiding this comment.
Sorry for the delay
Since this bug is here like forever, it means that almost nobody use HEAD requests ... :-/
|
We had actually some tests that used Anyway, thanks for taking a look! 👍 |
We recently noticed, that tsung will wait on HTTP
HEADrequests whenContent-Lengthheader is set to non-zero value.According to RFC2616 section 14.13:
So the
Content-Lengthheader - if present - will contain the expected response size for a non-HEAD request. Actually it is recommended thatContent-Lengthshould be present (also RFC2616 section 14.13):So it is considered "normal" that a HTTP HEAD requests contains a
Content-Lengthheader.This is the same with HTTP 1.0, according to RFC1945 Sec 10.4.
Issue
The problem in tsung was with
ts_http_common:check_resp_size/4. If headers are received completely and the content length is non-zero, we always expect more data. This resulted in tsung waiting indefinitely (until server closes connection).Solution
In case we have completely read the HTTP headers and in case of the HTTP verb is
HEAD, we are done reading the response, regardless whatContent-Lengthstates. In this case we can setack_donein#state_rcvtotrue.The problem can be reproduced using
Note that this host will respond with
Content-Length: