]> granicus.if.org Git - curl/commitdiff
- As reported independent by both Stan van de Burgt and Didier Brisebourg,
authorDaniel Stenberg <daniel@haxx.se>
Mon, 2 Nov 2009 18:49:56 +0000 (18:49 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 2 Nov 2009 18:49:56 +0000 (18:49 +0000)
  CURLINFO_SIZE_DOWNLOAD (the -w variable size_download) didn't work when
  getting data from ldap!

CHANGES
RELEASE-NOTES
lib/ldap.c

diff --git a/CHANGES b/CHANGES
index c58ccae1e26782a8de692df0ffe5d63f758a017c..cb3c43885dd9d0f798bf3cf9940b66e0129c05c1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,11 @@
 
                                   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)
 - 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)
index 5c74df455ff337838dcb962a638ed6b7bed173e5..e7142cc0fb755e38df747b0e390f8094d637f5cc 100644 (file)
@@ -45,6 +45,7 @@ This release includes the following bugfixes:
  o POST with Digest authentication and "Transfer-Encoding: chunked"
  o SCP connection re-use with wrong auth
  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:
 
@@ -58,6 +59,6 @@ advice from friends like these:
  Claes Jakobsson, Sven Anders, Chris Mumford, John P. McCaskey,
  Constantine Sapuntzakis, Michael Stillwell, Tom Mueller, Dan Fandrich,
  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)
index f440ee914bec1ed1c5a106c8897474435bd414f3..11d9f31f649b704b1d000e5de529e3ecea9a5116 100644 (file)
@@ -177,6 +177,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
   int ldap_ssl = 0;
   char *val_b64;
   size_t val_b64_sz;
+  curl_off_t dlsize=0;
 #ifdef LDAP_OPT_NETWORK_TIMEOUT
   struct timeval ldap_timeout = {10,0}; /* 10 sec connection/search timeout */
 #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 *)"\n", 1);
 
+    dlsize += strlen(dn)+5;
+
     for (attribute = ldap_first_attribute(server, entryIterator, &ber);
          attribute;
          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 *) attribute, 0);
           Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
+          dlsize += strlen(attribute)+3;
+
           if((strlen(attribute) > 7) &&
               (strcmp(";binary",
                       (char *)attribute +
                       (strlen((char *)attribute) - 7)) == 0)) {
             /* 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_len,
                                             &val_b64);
             if(val_b64_sz > 0) {
               Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, val_b64_sz);
               free(val_b64);
+              dlsize += val_b64_sz;
             }
-          } else
+          }
+          else {
             Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val,
                               vals[i]->bv_len);
+            dlsize += vals[i]->bv_len;
+          }
           Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0);
+          dlsize++;
         }
 
         /* Free memory used to store values */
         ldap_value_free_len(vals);
       }
       Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
-
+      dlsize++;
+      Curl_pgrsSetDownloadCounter(data, dlsize);
       ldap_memfree(attribute);
     }
     ldap_memfree(dn);