1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

deal with negative Content-Length: headers by ignoring the info

This commit is contained in:
Daniel Stenberg 2004-07-16 21:01:16 +00:00
parent 0359ae8f40
commit cd2e99e980

View File

@ -668,12 +668,21 @@ CURLcode Curl_readwrite(struct connectdata *conn,
if ((k->httpcode != 416) &&
checkprefix("Content-Length:", k->p)) {
contentlength = curlx_strtoofft(k->p+15, NULL, 10);
if (data->set.max_filesize && contentlength >
data->set.max_filesize) {
if (data->set.max_filesize &&
contentlength > data->set.max_filesize) {
failf(data, "Maximum file size exceeded");
return CURLE_FILESIZE_EXCEEDED;
}
if(contentlength >= 0)
conn->size = contentlength;
else {
/* Negative Content-Length is really odd, and we know it
happens for example when older Apache servers send large
files */
conn->bits.close = TRUE;
infof(data, "Negative content-length: %" FORMAT_OFF_T
", closing after transfer\n", contentlength);
}
}
/* check for Content-Type: header lines to get the mime-type */
else if (checkprefix("Content-Type:", k->p)) {