cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: FTP and CURLMOPT_PIPELINING

From: Dmitri Shubin <sbn_at_tbricks.com>
Date: Mon, 13 Dec 2010 14:37:26 +0300

Daniel Stenberg wrote:
> On Mon, 13 Dec 2010, Dmitri Shubin wrote:
>
>> Here is a patch to it:
>
> Can you provide the patch done with diff -u please?
>

--- ../../../../curl-7.21.2/docs/examples/multi-double.c
2010-10-11 01:22:27.000000000 +0400
+++ multi-double.c 2010-12-13 14:35:38.759888742 +0300
@@ -9,6 +9,8 @@
  * This is a very simple example using the multi interface.
  */
 
+#include <assert.h>
+
 #include <stdio.h>
 #include <string.h>
 
@@ -19,6 +21,30 @@
 /* curl stuff */
 #include <curl/curl.h>
 
+FILE *log_file = NULL;
+
+static int debug_func(CURL *curl_handle, curl_infotype info, char *ptr,
size_t size, void *userdata)
+{
+ char c = ptr[size];
+ ptr[size] = '\0';
+ switch (info) {
+ case CURLINFO_HEADER_IN:
+ fprintf(log_file, "%p\t< %s", curl_handle, ptr);
+ break;
+ case CURLINFO_HEADER_OUT:
+ fprintf(log_file, "%p\t> %s", curl_handle, ptr);
+ break;
+ }
+ ptr[size] = c;
+ fflush(log_file);
+ return 0;
+}
+
+static size_t write_func(void *ptr, size_t size, size_t nmemb, void
*userdata)
+{
+ return size*nmemb;
+}
+
 /*
  * Simply download two HTTP files!
  */
@@ -30,17 +56,26 @@
 
   int still_running; /* keep number of running handles */
 
+ log_file = fopen("curl.log", "w");
+
   http_handle = curl_easy_init();
   http_handle2 = curl_easy_init();
 
   /* set options */
- curl_easy_setopt(http_handle, CURLOPT_URL, "http://www.example.com/");
+ curl_easy_setopt(http_handle, CURLOPT_URL,
"ftp://ftp.kernel.org/bin/compress");
+ assert(curl_easy_setopt(http_handle, CURLOPT_DEBUGFUNCTION,
debug_func) == CURLE_OK);
+ assert(curl_easy_setopt(http_handle, CURLOPT_VERBOSE, (long)1) ==
CURLE_OK);
+ assert(curl_easy_setopt(http_handle, CURLOPT_WRITEFUNCTION,
write_func) == CURLE_OK);
 
   /* set options */
- curl_easy_setopt(http_handle2, CURLOPT_URL, "http://localhost/");
+ curl_easy_setopt(http_handle2, CURLOPT_URL,
"ftp://ftp.kernel.org/bin/ls");
+ assert(curl_easy_setopt(http_handle2, CURLOPT_DEBUGFUNCTION,
debug_func) == CURLE_OK);
+ assert(curl_easy_setopt(http_handle2, CURLOPT_VERBOSE, (long)1) ==
CURLE_OK);
+ assert(curl_easy_setopt(http_handle2, CURLOPT_WRITEFUNCTION,
write_func) == CURLE_OK);
 
   /* init a multi stack */
   multi_handle = curl_multi_init();
+ curl_multi_setopt(multi_handle, CURLMOPT_PIPELINING, (long)1);
 
   /* add the individual transfers */
   curl_multi_add_handle(multi_handle, http_handle);
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-12-13