Thank you, you was right. LibCurl was retrieving the data, it was this
function:
As you mentioned, it had a buffer that was causing the issue.
std::string StrFormat(const char* Format,...)
{
char Buf[512];
va_list va;
va_start(va,Format);
vsnprintf(Buf,sizeof(Buf),Format,va);
va_end(va);
return Buf;
}
-----Original Message-----
From: curl-library [mailto:[email protected]] On Behalf Of
Dan Fandrich
Sent: 14 June 2013 07:57
To: [email protected]
Subject: Re: CURLOPT_WRITEFUNCTION; Function not writing all data to disc
file?
On Thu, Jun 13, 2013 at 04:05:47PM +0100, Spencer Elliott wrote:
> I am very new to LibCurl, and am struggling with the
> CURLOPT_WRITEFUNCTION function.
>
> I have included my source code below, but essentially my issue is here:
>
> /*
>
> printf("\n");
>
> printf(response.c_str());
>
> printf("\n");
>
> LogToDisk(response);
>
> */
>
> The function that stores the data to a string seems to print the
> entire string out perfectly fine on the console using "printf".
> However, when it saves to disc file, there is a large amount of text
> missing. Can anyone help me understand what I am doing wrong?
If the data made it in to the string, then libcurl transferred it
successfully, so this is not really a libcurl question any longer.
You didn't provide the source code to LogToDisk() but rather LogToDisc();
not sure if that is relevant or just a typo. The code is passing the string
by value, not by reference, which is inefficient and for very, very large
strings, could fail due to lack of memory. It's also using another function
you don't explain, StrFormat. But, in using it, it's clear the string could
be copied internally an extra 3 times unnecessarily. If the data is
particularly large, then these 4 copies of the string could be using up all
the available memory.
It could also be that this StrFormat function has an internal limit on the
maximum size of the string it can format.
>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html