Make the Content-Length info override the Connection: close header, so that

libcurl will stop reading when the number of bytes have arrived and not wait
for a closed socket.
This commit is contained in:
Daniel Stenberg
2003-06-02 14:57:08 +00:00
parent 4f136a3a76
commit 06984df5cb

View File

@@ -457,11 +457,16 @@ CURLcode Curl_readwrite(struct connectdata *conn,
*/ */
if(data->set.no_body) if(data->set.no_body)
stop_reading = TRUE; stop_reading = TRUE;
else if(!conn->bits.close) { else {
/* If this is not the last request before a close, we must /* If we know the expected size of this document, we set the
set the maximum download size to the size of the maximum download size to the size of the expected
expected document or else, we won't know when to stop document or else, we won't know when to stop reading!
reading! */
Note that we set the download maximum even if we read a
"Connection: close" header, to make sure that
"Content-Length: 0" still prevents us from attempting to
read the (missing) response-body.
*/
if(-1 != conn->size) if(-1 != conn->size)
conn->maxdownload = conn->size; conn->maxdownload = conn->size;
} }