cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: FW: HTTP GET using easycurl - HTTP chunks in HTTP response.

From: Rangoli Mathur <Rangoli.Mathur_at_wnco.com>
Date: Thu, 14 Dec 2006 09:24:02 -0600

> -----Original Message-----
> From: curl-library-bounces_at_cool.haxx.se
> [mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of
> Daniel Stenberg
> Sent: Thursday, December 14, 2006 3:56 AM
> To: libcurl development
> Subject: RE: FW: HTTP GET using easycurl - HTTP chunks in
> HTTP response.
>
> On Wed, 13 Dec 2006, Rangoli Mathur wrote:
>
> >> That does look like a bug. Does the curl command-line tool do the
> >> same on the same URL?
>
> > I tried the curl command line tool doesn't pose this problem. The
> > response from curl coagulated all the HTTP chunks, (I made sure the
> > transfer encoding is still chunked). So, the issue, then
> lies in libcurl?
>
> curl uses libcurl for all transfer-related stuff so if curl
> can do this, it implies that libcurl can.
>
> It then of course calls for the question: why isn't this
> working for you when you use libcurl directly when curl can
> do it right when using libcurl?
>
> I would suspect that your write callback is broken, but
> that's only a guess since you haven't showed us that.
>

This is what the entire test program looks like.
In write_data function I am just gathering the data, so I can see the
response after the perform call returns.

#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
#include <iostream>

using namespace std;

string strData = "";

size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{
  strData += ((char*) ptr);
  return (nmemb * size);
}

int main(int argc, char **argv)
  CURL *curl_handle;
  curl_global_init(CURL_GLOBAL_ALL);

  curl_handle = curl_easy_init();
  curl_easy_setopt(curl_handle, CURLOPT_PROXY,
"proxy.swacorp.com:8080");
  curl_easy_setopt(curl_handle, CURLOPT_URL, "http://www.yahoo.com");
  curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1);
  curl_easy_setopt(curl_handle, CURLOPT_HEADER, 1);
  curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
  curl_easy_perform(curl_handle);
  cout<<"RESULT : "<<strData<<endl;
  strData = "";

  curl_easy_cleanup(curl_handle);
  return 0;
}

> --
> Commercial curl and libcurl Technical Support:
> http://haxx.se/curl.html
>
Received on 2006-12-14