Don't assume a 416 response has no body

* http.c(gethttp): In case of a 416 response, try to drain the socket of
any bytes before reusing the connection

Reported-By: Iru Cai <mytbk920423@gmail.com>
This commit is contained in:
Darshit Shah 2017-12-08 18:13:00 +01:00
parent 6aa6b669ef
commit 693cee0109

View File

@ -3969,11 +3969,16 @@ gethttp (const struct url *u, struct url *original_url, struct http_stat *hs,
hs->res = 0;
/* Mark as successfully retrieved. */
*dt |= RETROKF;
if (statcode == HTTP_STATUS_RANGE_NOT_SATISFIABLE)
/* Try to maintain the keep-alive connection. It is often cheaper to
* consume some bytes which have already been sent than to negotiate
* a new connection. However, if the body is too large, or we don't
* care about keep-alive, then simply terminate the connection */
if (keep_alive &&
skip_short_body (sock, contlen, chunked_transfer_encoding))
CLOSE_FINISH (sock);
else
CLOSE_INVALIDATE (sock); /* would be CLOSE_FINISH, but there
might be more bytes in the body. */
CLOSE_INVALIDATE (sock);
retval = RETRUNNEEDED;
goto cleanup;
}