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

- As reported independent by both Stan van de Burgt and Didier Brisebourg,

CURLINFO_SIZE_DOWNLOAD (the -w variable size_download) didn't work when
  getting data from ldap!
This commit is contained in:
Daniel Stenberg 2009-11-02 18:49:56 +00:00
parent 41de897b6b
commit b19dc0eeb0
3 changed files with 21 additions and 4 deletions

View File

@ -6,6 +6,11 @@
Changelog Changelog
Daniel Stenberg (2 Nov 2009)
- As reported independent by both Stan van de Burgt and Didier Brisebourg,
CURLINFO_SIZE_DOWNLOAD (the -w variable size_download) didn't work when
getting data from ldap!
Daniel Stenberg (31 Oct 2009) Daniel Stenberg (31 Oct 2009)
- Gabriel Kuri reported a problem with CURLINFO_CONTENT_LENGTH_DOWNLOAD if the - Gabriel Kuri reported a problem with CURLINFO_CONTENT_LENGTH_DOWNLOAD if the
download was 0 bytes, as libcurl would then return the size as unknown (-1) download was 0 bytes, as libcurl would then return the size as unknown (-1)

View File

@ -45,6 +45,7 @@ This release includes the following bugfixes:
o POST with Digest authentication and "Transfer-Encoding: chunked" o POST with Digest authentication and "Transfer-Encoding: chunked"
o SCP connection re-use with wrong auth o SCP connection re-use with wrong auth
o CURLINFO_CONTENT_LENGTH_DOWNLOAD for 0 bytes transfers o CURLINFO_CONTENT_LENGTH_DOWNLOAD for 0 bytes transfers
0 CURLINFO_SIZE_DOWNLOAD for ldap transfers (-w size_download)
This release includes the following known bugs: This release includes the following known bugs:
@ -58,6 +59,6 @@ advice from friends like these:
Claes Jakobsson, Sven Anders, Chris Mumford, John P. McCaskey, Claes Jakobsson, Sven Anders, Chris Mumford, John P. McCaskey,
Constantine Sapuntzakis, Michael Stillwell, Tom Mueller, Dan Fandrich, Constantine Sapuntzakis, Michael Stillwell, Tom Mueller, Dan Fandrich,
Kevin Baughman, John Dennis, Ray Dassen, Johan van Selst, Dima Barsky, Kevin Baughman, John Dennis, Ray Dassen, Johan van Selst, Dima Barsky,
Liza Alenchery, Gabriel Kuri Liza Alenchery, Gabriel Kuri, Stan van de Burgt, Didier Brisebourg
Thanks! (and sorry if I forgot to mention someone) Thanks! (and sorry if I forgot to mention someone)

View File

@ -177,6 +177,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
int ldap_ssl = 0; int ldap_ssl = 0;
char *val_b64; char *val_b64;
size_t val_b64_sz; size_t val_b64_sz;
curl_off_t dlsize=0;
#ifdef LDAP_OPT_NETWORK_TIMEOUT #ifdef LDAP_OPT_NETWORK_TIMEOUT
struct timeval ldap_timeout = {10,0}; /* 10 sec connection/search timeout */ struct timeval ldap_timeout = {10,0}; /* 10 sec connection/search timeout */
#endif #endif
@ -383,6 +384,8 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)dn, 0); Curl_client_write(conn, CLIENTWRITE_BODY, (char *)dn, 0);
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
dlsize += strlen(dn)+5;
for (attribute = ldap_first_attribute(server, entryIterator, &ber); for (attribute = ldap_first_attribute(server, entryIterator, &ber);
attribute; attribute;
attribute = ldap_next_attribute(server, entryIterator, ber)) attribute = ldap_next_attribute(server, entryIterator, ber))
@ -396,30 +399,38 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
Curl_client_write(conn, CLIENTWRITE_BODY, (char *) attribute, 0); Curl_client_write(conn, CLIENTWRITE_BODY, (char *) attribute, 0);
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2); Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
dlsize += strlen(attribute)+3;
if((strlen(attribute) > 7) && if((strlen(attribute) > 7) &&
(strcmp(";binary", (strcmp(";binary",
(char *)attribute + (char *)attribute +
(strlen((char *)attribute) - 7)) == 0)) { (strlen((char *)attribute) - 7)) == 0)) {
/* Binary attribute, encode to base64. */ /* Binary attribute, encode to base64. */
val_b64_sz = Curl_base64_encode(conn->data, val_b64_sz = Curl_base64_encode(data,
vals[i]->bv_val, vals[i]->bv_val,
vals[i]->bv_len, vals[i]->bv_len,
&val_b64); &val_b64);
if(val_b64_sz > 0) { if(val_b64_sz > 0) {
Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, val_b64_sz); Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, val_b64_sz);
free(val_b64); free(val_b64);
dlsize += val_b64_sz;
} }
} else }
else {
Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val, Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val,
vals[i]->bv_len); vals[i]->bv_len);
dlsize += vals[i]->bv_len;
}
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0); Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0);
dlsize++;
} }
/* Free memory used to store values */ /* Free memory used to store values */
ldap_value_free_len(vals); ldap_value_free_len(vals);
} }
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
dlsize++;
Curl_pgrsSetDownloadCounter(data, dlsize);
ldap_memfree(attribute); ldap_memfree(attribute);
} }
ldap_memfree(dn); ldap_memfree(dn);