cURL / Mailing Lists / curl-library / Single Mail


Re: Issues on callback write_data

From: Gustavo Elias Siqueira <>
Date: Sun, 25 Mar 2007 17:42:52 -0300

> On Fri, 23 Mar 2007, Gustavo Elias Siqueira wrote:
> I'm a beginner curl user, asking for a hand to solve a problem.
> When I call curl to perform, the libcurl at the
> first callback write_data, returns a buffer with 1100 and show a parcial
> data.For the second time, the buffer returns me 1768, but theres no data
> avaiable.

> On Fri, 23 Mar 2007 22:20:02 +0100 (CET), Daniel Stenberg wrote:
> When you copy the getinmemory.c example, make sure you also copy the

Ok...Did it!

> On Fri, 23 Mar 2007 14:44:46 -0700, Dan Fandrich wrote:
> You're using a pointer (data) that has never been set in your program.
> It's just going to contain garbage, if anything. You need to allocate
> space for your MemoryStruct structure somewhere and pass in the pointer
> using the CURLOPT_WRITEDATA option. Then, after curl_easy_perform
> returns, you use the same pointer to access the downloaded data.

Ok...Did it!

But the issue still remains...
The second callback have a bigger size, but no data avaiable. After
curl_easy_perform, that's all I got in the first one:

"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html
lang="en"><head><title> - Breaking News, U.S., World, Weather,
Entertainment &amp; Video News</title> <meta http-equiv="content-type"
content="text/html; charset=iso-8859-1">"

> On 24 Mar 2007 23:23:00 -0700, Dan Fandrich wrote
> Just where are you looking at the data? It's not in the code you sent.
> And what do you mean by "no data available"? You just showed some data.
> And what does "first one" refer to? Are you talking about the first
> call to the callback? You do understand that the data is sent to the
> write callback in chunks, don't you? So you need to wait until
> curl_easy_perform returns before you can see it all in the buffer.

I put some breakpoints right after perform line, and both chunk.memory and *mem
just got a parcial data.
The write_data function is called by libcurl 2 times during the perform, but
the data that I showed to you, I got at the fist callback...nothing in the
second one.
Using the standart mode (stdout), works fine, getting all data!
Received on 2007-03-25