cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Chunk size in WriteCallback

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 21 Mar 2013 09:48:49 +0100 (CET)

On Thu, 21 Mar 2013, Ajay Tanpure wrote:

> I am using the WriteCallback function to get the response sent by the server
> in the memory.
>
> How should i deal with NULL character in WriteCallback function to allocate
> memory?

(First, you're talking libcurl stuff so the curl-library list would be a more
appropriate list than this and would reach the proper "crowd". I'm CC'ing my
response over there now.)

libcurl tells you the size of the data chunk and hands it to you. It always
treats data as a plain blob with potentially binary contents. The callback
example in getinmemory.c does as well and it has no problems with embedded
zero bytes in the data stream.

You just need to never try strlen() or any other function on the data that
assumes a trailing zero byte to signal the end of it.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2013-03-21