curl-library
Re: http error with CURLOPT_RESUME_FROM CURLOPT_FAILONERROR
Date: Tue, 25 Nov 2003 07:40:14 -0800
I am using 7.10.5 on windows. I have just changed my code to grab the
header first and look to see what the remote size is and then test that
with what the local file size. That works good enough for me. I do
have another question. Am I guaranteed to have the same format of the
header for every http server? In other words will this work for some
one that is using a linux http server and someone else that is running a
windows http server? All I am doing is writing the header to a file,
then looking for "Content-Length:" and grabbing the number after it.
Will that format be the same for every http server? I am sorry if that
is an http standard and its a dumb question, I don't know a lot about
http. Thanks in advance!
zach
Daniel Stenberg wrote:
>On Mon, 24 Nov 2003, zach diubaldo wrote:
>
>
>
>>Hey all, I am having some problems with downloading a file and using
>>CURLOPT_FAILONERROR and CURLOPT_RESUME_FROM at the same time.
>>
>>
>
>... using what libcurl version on what platform?
>
>
>
>>curl_easy_setopt( pcurl, CURLOPT_CONNECTTIMEOUT, 60 );
>>curl_easy_setopt( pcurl, CURLOPT_FAILONERROR, TRUE );
>>curl_easy_setopt( pcurl, CURLOPT_RESUME_FROM, file_size );
>>curl_easy_setopt( pcurl, CURLOPT_BUFFERSIZE, 14000 );
>>curl_status = curl_easy_perform( pcurl );
>>
>>My problem is when the file has already been downloaded. I use the return
>>from curl_easy_perform() to determine if file that I am download exits, if
>>it doesn't curl_status = CURLE_HTTP_RETURNED_ERROR. That is what I would
>>expect and that is good by me. The problem occurs when the file is valid,
>>but has already been downloaded. Even if the file has been downloaded in
>>full the above code is executed. When it does curl_status =
>>CURLE_HTTP_RETURNED_ERROR.
>>
>>
>
>The problem with using this approach is that HTTP servers normally actually DO
>return an error for this kind of operation. I've had a hard time to actually
>decide what libcurl should do on this use case (and make it consistent with
>how it works for FTP).
>
>The problem is that when you try to resume from 'file size' the HTTP server
>will return an error saying that you've tried to download a range that is
>outside the file's size. In 7.10.8 I've tried to deal with this (HTTP error
>code 416), but I'm not 100% satisfied yet as I'm having a hard time deciding
>what the correct behavior should be.
>
>
>
>>I guess I could grab the size of the file from the http headers and not
>>download if I already have the file, but I would rather not have to parse
>>the http header to find the size. Any one have any thoughts on this?
>>
>>
>
>At the moment I don't think I can come up with a better idea.
>
>
>
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
Received on 2003-11-25