curl-library
Re: questions about http resuming download
Date: Tue, 09 Sep 2008 02:40:32 -0400
ianguo_at_linpus.com wrote:
> Hi all,
>
> Could I ask 2 questions:
> 1. how to get the size of a file which I want to download from server
> using http?
> 2. I use parameter CURLOPT_RESUME_FROM to perform resuming download
> (http), but when the resuming point is equal to the size of file in
> server(that means the file is already downloaded successfully), server
> will return error (error code:CURLE_PARTIAL_FILE 18).How to avoid or
> deal with this error to make resuming download OK?
>
> Thank you!
>
> Best Regards,
> Ian
>
>
>
Dear Ian:
1: Content-Length header?
14.13 Content-Length
The Content-Length entity-header field indicates the size of the entity-body,
in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD
method, the size of the entity-body that would have been sent had the request
been a GET.
Content-Length = "Content-Length" ":" 1*DIGIT
An example is
Content-Length: 3495
Applications SHOULD use this field to indicate the transfer-length of the
message-body, unless this is prohibited by the rules in section 4.4.
Any Content-Length greater than or equal to zero is a valid value. Section 4.4
describes how to determine the length of a message-body if a Content-Length is
not given.
Note that the meaning of this field is significantly different from the
corresponding definition in MIME, where it is an optional field used within
the "message/external-body" content-type. In HTTP, it SHOULD be sent whenever
the message's length can be determined prior to being transferred, unless this
is prohibited by the rules in section 4.4.
Thanks
Wei
Received on 2008-09-09