cURL / Mailing Lists / curl-library / Single Mail


Re: Fwd: Downloaded File (.pdf) Corrupt

From: Eric Belec <>
Date: Mon, 9 Jan 2012 10:58:19 -0500

On 1/7/2012 4:39 PM, Dan Fandrich wrote:
> On Sat, Jan 07, 2012 at 03:11:28PM -0500, Eric Belec wrote:
>> libcurl (.net) with C# :
>> I determined that 9 out of 10 times downloading my various pdf files will work.
>> The problem is the 1 of 10 times where the pdf returned was 22kb (and corrupt)
>> instead of a working pdf of size 40kb...
>> Please let me know if there is an alternate way I can write my pdf out.. I've
>> spent so much time and I'm at the end of the ropes.. Any help would be
>> appreciated! Below is the key code areas..
>> public Int32 OnWriteFile(Byte[] buf, Int32 size, Int32 nmemb, Object
>> extraData)
>> {
>> binaryWriter.Write(buf, 0, nmemb);
> This should be size * nmemb as well.
>> return size * nmemb;
>> }
> Are you sure the source PDF file isn't actually corrupt? Are you sure the
> server isn't actually corrupting it somehow? Can you download the file
> another way and tell? If you download the file from the same URL using
> another program, is it corrupt? In what way is it corrupt? Is it simply
> truncated? Are the non-truncated bytes correct? What do you see in the
> transfer with logging enabled? What is the value returned by
> easy.Perform()?
>>>> Dan
> -------------------------------------------------------------------
> List admin:
> Etiquette:

Thank you for the reply. I've determined the scenario where
Chrome/Firefox works where libcurl does not. If you look at the link ->
you will notice an added "amp;" which Chrome/Firefox appears ignore and
unfortunetely libcurl does not resulting in a corrupt downoad. Can
someone explain why this might be happening and also the best short term
fix? I assume I could just parse my link and remove the added 'amp;' but
there has to be a better solution.

Please let me know.

List admin:
Received on 2012-01-09