diff --git a/lib/ftp.c b/lib/ftp.c index 4c4396abbe0b362c67dff9806d2a84972ed5e2dd..715afc2f2610414cff3333e856e03a228c3e2dce 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -4470,8 +4470,8 @@ CURLcode ftp_regular_transfer(struct connectdata *conn, Curl_pgrsSetUploadCounter(data, 0); Curl_pgrsSetDownloadCounter(data, 0); - Curl_pgrsSetUploadSize(data, 0); - Curl_pgrsSetDownloadSize(data, 0); + Curl_pgrsSetUploadSize(data, -1); + Curl_pgrsSetDownloadSize(data, -1); ftpc->ctl_valid = TRUE; /* starts good */ diff --git a/lib/http.c b/lib/http.c index 3fdab27eee1d7bac7c6486b3962d58e069188a47..35baa3407d57d9f483bf8b56340d8ef1c4a76741 100644 --- a/lib/http.c +++ b/lib/http.c @@ -2351,7 +2351,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) return result; http->postdata = NULL; /* nothing to post at this point */ - Curl_pgrsSetUploadSize(data, 0); /* upload size is 0 atm */ + Curl_pgrsSetUploadSize(data, -1); /* upload size is unknown atm */ /* If 'authdone' is FALSE, we must not set the write socket index to the Curl_transfer() call below, as we're not ready to actually upload any diff --git a/lib/imap.c b/lib/imap.c index e80bc03c13b79401675c9d935b2064c56fa851da..9fc472866d14a1166fc9713639dbc8ca0e4aaede 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -1662,7 +1662,7 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode, (void)instate; /* no use for this yet */ if(imapcode != '*') { - Curl_pgrsSetDownloadSize(data, 0); + Curl_pgrsSetDownloadSize(data, -1); state(conn, IMAP_STOP); return CURLE_REMOTE_FILE_NOT_FOUND; /* TODO: Fix error code */ } @@ -2336,8 +2336,8 @@ static CURLcode imap_regular_transfer(struct connectdata *conn, /* Set the progress data */ Curl_pgrsSetUploadCounter(data, 0); Curl_pgrsSetDownloadCounter(data, 0); - Curl_pgrsSetUploadSize(data, 0); - Curl_pgrsSetDownloadSize(data, 0); + Curl_pgrsSetUploadSize(data, -1); + Curl_pgrsSetDownloadSize(data, -1); /* Carry out the perform */ result = imap_perform(conn, &connected, dophase_done); diff --git a/lib/pop3.c b/lib/pop3.c index e69f5c5cf233d711d6d436d8a3dd42a330e00274..dc64f81065200836ad67776f59a455abff469e89 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -1935,8 +1935,8 @@ static CURLcode pop3_regular_transfer(struct connectdata *conn, /* Set the progress data */ Curl_pgrsSetUploadCounter(data, 0); Curl_pgrsSetDownloadCounter(data, 0); - Curl_pgrsSetUploadSize(data, 0); - Curl_pgrsSetDownloadSize(data, 0); + Curl_pgrsSetUploadSize(data, -1); + Curl_pgrsSetDownloadSize(data, -1); /* Carry out the perform */ result = pop3_perform(conn, &connected, dophase_done); diff --git a/lib/progress.c b/lib/progress.c index e6a8d825a663398e00e397bc405361905e75a0ba..f147ce71ee531d783665679865c6d48f85acea00 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -159,8 +159,8 @@ void Curl_pgrsResetTimesSizes(struct SessionHandle *data) data->progress.t_pretransfer = 0.0; data->progress.t_starttransfer = 0.0; - Curl_pgrsSetDownloadSize(data, 0); - Curl_pgrsSetUploadSize(data, 0); + Curl_pgrsSetDownloadSize(data, -1); + Curl_pgrsSetUploadSize(data, -1); } void Curl_pgrsTime(struct SessionHandle *data, timerid timer) @@ -234,20 +234,26 @@ void Curl_pgrsSetUploadCounter(struct SessionHandle *data, curl_off_t size) void Curl_pgrsSetDownloadSize(struct SessionHandle *data, curl_off_t size) { - data->progress.size_dl = size; - if(size >= 0) + if(size >= 0) { + data->progress.size_dl = size; data->progress.flags |= PGRS_DL_SIZE_KNOWN; - else + } + else { + data->progress.size_dl = 0; data->progress.flags &= ~PGRS_DL_SIZE_KNOWN; + } } void Curl_pgrsSetUploadSize(struct SessionHandle *data, curl_off_t size) { - data->progress.size_ul = size; - if(size >= 0) + if(size >= 0) { + data->progress.size_ul = size; data->progress.flags |= PGRS_UL_SIZE_KNOWN; - else + } + else { + data->progress.size_ul = 0; data->progress.flags &= ~PGRS_UL_SIZE_KNOWN; + } } /* diff --git a/lib/smtp.c b/lib/smtp.c index 4dc78497c8943dffddf44579330ee25de08bf6e1..9aa8b15bd73991eca5541068260f922b94a7551d 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -2031,8 +2031,8 @@ static CURLcode smtp_regular_transfer(struct connectdata *conn, /* Set the progress data */ Curl_pgrsSetUploadCounter(data, 0); Curl_pgrsSetDownloadCounter(data, 0); - Curl_pgrsSetUploadSize(data, 0); - Curl_pgrsSetDownloadSize(data, 0); + Curl_pgrsSetUploadSize(data, -1); + Curl_pgrsSetDownloadSize(data, -1); /* Carry out the perform */ result = smtp_perform(conn, &connected, dophase_done); diff --git a/lib/ssh.c b/lib/ssh.c index b248b43a08abaa53b00493e80a70c7af8481043c..887e10f21ca9c9d9e46bbd656c5847bc76328c5d 100644 --- a/lib/ssh.c +++ b/lib/ssh.c @@ -2878,8 +2878,8 @@ static CURLcode ssh_do(struct connectdata *conn, bool *done) Curl_pgrsSetUploadCounter(data, 0); Curl_pgrsSetDownloadCounter(data, 0); - Curl_pgrsSetUploadSize(data, 0); - Curl_pgrsSetDownloadSize(data, 0); + Curl_pgrsSetUploadSize(data, -1); + Curl_pgrsSetDownloadSize(data, -1); if(conn->handler->protocol & CURLPROTO_SCP) res = scp_perform(conn, &connected, done); diff --git a/tests/data/test579 b/tests/data/test579 index adbb3dd22854f3b8791a61d5646488a1b14f8c9f..e352e3d602ec244eb4e8cb71190edda449abee58 100644 --- a/tests/data/test579 +++ b/tests/data/test579 @@ -77,12 +77,11 @@ http://%HOSTIP:%HTTPPORT/579 log/ip579 Progress callback called with UL 0 out of 0 -Progress callback called with UL 0 out of -1 -Progress callback called with UL 8 out of -1 -Progress callback called with UL 16 out of -1 -Progress callback called with UL 26 out of -1 -Progress callback called with UL 61 out of -1 -Progress callback called with UL 66 out of -1 +Progress callback called with UL 8 out of 0 +Progress callback called with UL 16 out of 0 +Progress callback called with UL 26 out of 0 +Progress callback called with UL 61 out of 0 +Progress callback called with UL 66 out of 0 diff --git a/tests/data/test599 b/tests/data/test599 index c57fe5c919fc0f39f2cf5d0fef44641bab39bd2f..9ce8b234c0f67330cfd21009bc728012e3e7e56b 100644 --- a/tests/data/test599 +++ b/tests/data/test599 @@ -71,13 +71,15 @@ lib599 HTTP GET with progress callback and redirects changing content sizes -http://%HOSTIP:%HTTPPORT/599 +http://%HOSTIP:%HTTPPORT/599 log/ip599 # # Verify data after the test has been "shot" - + +CL: -1 + diff --git a/tests/libtest/lib599.c b/tests/libtest/lib599.c index 6b092677a0f03814fba8966ec8a118760722a2cf..08c536c7215bed186e491498fba374ede3722759 100644 --- a/tests/libtest/lib599.c +++ b/tests/libtest/lib599.c @@ -43,6 +43,7 @@ int test(char *URL) { CURL *curl; CURLcode res=CURLE_OK; + double content_length = 0.0; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); @@ -74,6 +75,17 @@ int test(char *URL) /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + if (!res) { + FILE *moo; + res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, + &content_length); + moo = fopen(libtest_arg2, "wb"); + if (moo) { + fprintf(moo, "CL: %.0f\n", content_length); + fclose(moo); + } + } + test_cleanup: /* always cleanup */