cURL / Mailing Lists / curl-library / Single Mail


Fwd: http resume

From: Eduardo García <>
Date: Wed, 25 Feb 2004 13:39:22 +0100

Hello again,

         Taking again my problems using curllib, while yet waiting from
this list some help on them, I have realized that there is no useful to
check the begining of the file as far as there are too much possibilities
to begin an web-served-error-page ("<html...", "<?xml...",
"<!CONTENT_TYPE..."...), so I need a way to know from curllib when I am
downloading an error from the server instead of the file I ask for.

         And for the second problem, I specified a debug function to curl
in order to trace comms with the server (CURLOPT_STDERR with a FILE* handle
doesn't work and crashes), and this is what I got (just dumped text and
data together):

Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*

HTTP/1.1 206 Partial content
Server: Microsoft-IIS/5.0
Date: Tue, 24 Feb 2004 10:29:14 GMT
Content-Type: application/octet-stream
Last-Modified: Tue, 17 Feb 2004 21:16:26 GMT
ETag: "4ee37f4d9bf5c31:154a"
Content-Length: 765567
Content-Range: bytes 1039-766605/766606
Age: 2
MZ ÿÿ ¸.... (downloaded bytes here) ..... Connection #0 left intact

         As you can check I am receiving the first bytes of the file
("MZ....", it was a file zip) instead of getting bytes from 1039...
What can I do to prevent that or to know it from curllib before appending
the newly downloaded wrong bytes to my file on disk ?

I would greatly appreciate any help on these matters.

Eduardo García

>Date: Mon, 23 Feb 2004 20:32:05 +0100
>From: Eduardo García <>
>Subject: http resume
> I am a newbie to curlib. Just now I am using it to get some
> (binary) files from a web server in my application. I am using v.7.10.8
> from C code over WindowsXP SP1.
>I am having two problems, one of them I am really unable to solve.
> In the first place, I don't know how to get an error from libcurl
> whenever the file I want to download is not in the server, or the server
> didn't allow me to get access to it: curlLib just get a little file and
> returns OK. Just now I am suppossing the server (if connected) returns an
> http-formatted human-readable error, and so I am checking if the writting
> callback if the very first bytes of the file are "<html>". If so, I
> return 0 in order to abort the download. Is this the only way to get curl
> to returns a failure in these cases?
> On the other hand, as far as I must download quite big-sized
> files, I would like to resume downloads when available data is in my
> local disk and the server supports this operation. I am testing with a
> server which doesn't support resume (as far as I can see from the
> results, and check by using verboursly comand line version of curl). When
> I set CURLOPT_RESUME_FROM I get Ok from curl_easy_perform, while the
> downloaded result is a buffer just sized=(totalFileSize - resumedBytes),
> but starting from the beggining of the file !!!
> How can I realize the server doesn't support resume before having
> (wrongly) downloaded all the file ? How can I get Curl to return me that error?
>As far as command line curl shows that at the very beggining of the
>downloading, I asume curllib knows it....
> I have try to use CURLOPT_VERBOSE + CURLOPT_STDERR over an opened
> FILE* (fopen("filename","w")) in order to check the process in depth but
> then I get a crash....
>Thanks for your sure help !!
>Eduardo García
Received on 2004-02-25