mirror of https://github.com/moparisthebest/curl
Alexander Krasnostavsky made the write callback get called even when a zero
byte file is downloaded.
This commit is contained in:
parent
c3d74ffe48
commit
cd52b9f0da
4
CHANGES
4
CHANGES
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
|
Daniel (20 August 2004)
|
||||||
|
- Alexander Krasnostavsky made the write callback get called even when a zero
|
||||||
|
byte file is downloaded.
|
||||||
|
|
||||||
Daniel (18 August 2004)
|
Daniel (18 August 2004)
|
||||||
- Ling Thio pointed out that when libcurl is built ipv6-enabled, it still did
|
- Ling Thio pointed out that when libcurl is built ipv6-enabled, it still did
|
||||||
reverse DNS lookups when fed with a numerical IP-address (like
|
reverse DNS lookups when fed with a numerical IP-address (like
|
||||||
|
|
|
@ -14,6 +14,7 @@ This release includes the following changes:
|
||||||
|
|
||||||
This release includes the following bugfixes:
|
This release includes the following bugfixes:
|
||||||
|
|
||||||
|
o downloading empty files now calls the write callback properly
|
||||||
o no more reverse DNS lookups when getting ip-only address with ipv6-enabled
|
o no more reverse DNS lookups when getting ip-only address with ipv6-enabled
|
||||||
libcurl
|
libcurl
|
||||||
o libcurl works better multi-threaded on AIX (when built with xlc)
|
o libcurl works better multi-threaded on AIX (when built with xlc)
|
||||||
|
|
|
@ -44,10 +44,6 @@ may have been fixed since this was written!
|
||||||
libcurl thinks of it as the *compressed* lenght. Some explanations are here:
|
libcurl thinks of it as the *compressed* lenght. Some explanations are here:
|
||||||
http://curl.haxx.se/mail/lib-2003-06/0146.html
|
http://curl.haxx.se/mail/lib-2003-06/0146.html
|
||||||
|
|
||||||
* Downloading 0 (zero) bytes files over FTP will not create a zero byte file
|
|
||||||
locally, which is because libcurl doesn't call the write callback with zero
|
|
||||||
bytes. Explained here: http://curl.haxx.se/mail/archive-2003-04/0143.html
|
|
||||||
|
|
||||||
* IPv6 support on AIX 4.3.3 doesn't work due to a missing sockaddr_storage
|
* IPv6 support on AIX 4.3.3 doesn't work due to a missing sockaddr_storage
|
||||||
struct. It has been reported to work on AIX 5.1 though.
|
struct. It has been reported to work on AIX 5.1 though.
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||||
if((k->keepon & KEEP_READ) &&
|
if((k->keepon & KEEP_READ) &&
|
||||||
(!readfdp || FD_ISSET(conn->sockfd, readfdp))) {
|
(!readfdp || FD_ISSET(conn->sockfd, readfdp))) {
|
||||||
|
|
||||||
bool readdone = TRUE;
|
bool is_empty_data = FALSE;
|
||||||
|
|
||||||
/* This is where we loop until we have read everything there is to
|
/* This is where we loop until we have read everything there is to
|
||||||
read or we get a EWOULDBLOCK */
|
read or we get a EWOULDBLOCK */
|
||||||
|
@ -279,9 +279,11 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||||
}
|
}
|
||||||
|
|
||||||
didwhat |= KEEP_READ;
|
didwhat |= KEEP_READ;
|
||||||
|
/* indicates data of zero size, i.e. empty file */
|
||||||
|
is_empty_data = (nread == 0 && k->bodywrites == 0);
|
||||||
|
|
||||||
/* NULL terminate, allowing string ops to be used */
|
/* NULL terminate, allowing string ops to be used */
|
||||||
if (0 < nread)
|
if (0 < nread || is_empty_data)
|
||||||
k->buf[nread] = 0;
|
k->buf[nread] = 0;
|
||||||
|
|
||||||
/* if we receive 0 or less here, the server closed the connection and
|
/* if we receive 0 or less here, the server closed the connection and
|
||||||
|
@ -289,7 +291,6 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||||
else if (0 >= nread) {
|
else if (0 >= nread) {
|
||||||
k->keepon &= ~KEEP_READ;
|
k->keepon &= ~KEEP_READ;
|
||||||
FD_ZERO(&k->rkeepfd);
|
FD_ZERO(&k->rkeepfd);
|
||||||
readdone = TRUE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -922,9 +923,9 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||||
/* This is not an 'else if' since it may be a rest from the header
|
/* This is not an 'else if' since it may be a rest from the header
|
||||||
parsing, where the beginning of the buffer is headers and the end
|
parsing, where the beginning of the buffer is headers and the end
|
||||||
is non-headers. */
|
is non-headers. */
|
||||||
if (k->str && !k->header && (nread > 0)) {
|
if (k->str && !k->header && (nread > 0 || is_empty_data)) {
|
||||||
|
|
||||||
if(0 == k->bodywrites) {
|
if(0 == k->bodywrites && !is_empty_data) {
|
||||||
/* These checks are only made the first time we are about to
|
/* These checks are only made the first time we are about to
|
||||||
write a piece of the body */
|
write a piece of the body */
|
||||||
if(conn->protocol&PROT_HTTP) {
|
if(conn->protocol&PROT_HTTP) {
|
||||||
|
@ -1037,7 +1038,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||||
|
|
||||||
Curl_pgrsSetDownloadCounter(data, k->bytecount);
|
Curl_pgrsSetDownloadCounter(data, k->bytecount);
|
||||||
|
|
||||||
if(!conn->bits.chunk && (nread || k->badheader)) {
|
if(!conn->bits.chunk && (nread || k->badheader || is_empty_data)) {
|
||||||
/* If this is chunky transfer, it was already written */
|
/* If this is chunky transfer, it was already written */
|
||||||
|
|
||||||
if(k->badheader && !k->ignorebody) {
|
if(k->badheader && !k->ignorebody) {
|
||||||
|
@ -1094,7 +1095,14 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||||
|
|
||||||
} /* if (! header and data to read ) */
|
} /* if (! header and data to read ) */
|
||||||
|
|
||||||
} while(!readdone);
|
if (is_empty_data) {
|
||||||
|
/* if we received nothing, the server closed the connection and we
|
||||||
|
are done */
|
||||||
|
k->keepon &= ~KEEP_READ;
|
||||||
|
FD_ZERO(&k->rkeepfd);
|
||||||
|
}
|
||||||
|
|
||||||
|
} while(0);
|
||||||
|
|
||||||
} /* if( read from socket ) */
|
} /* if( read from socket ) */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue