cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: http resume, libcurl ignoring the 206 status code.

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sat, 3 Mar 2007 22:41:08 +0100 (CET)

On Sat, 3 Mar 2007, Nathan E. Moore wrote:

> When sending a range request to a http server libcurl only looks for a
> Content-Range header in the response. If this header is not present a error
> is issued and the download aborted. Even if the server responded with a 206
> response code, and actually send the requested ranges.
>
> Nothing in http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16
> indicates that a Content-Range header is required for a partial content
> response. By my reading of it the header is only required to not be a *
> with a 206.

I agree, I read it that way as well. I think the current code ended up like
this more based on how existing server implementations have responded than
what the standards say.

> I have only tried so far using the CURLOPT_RESUME_FROM option. I suppose
> there is a chance that setting the range request using CURLOPT_HTTPHEADER
> may work around libcurl's checks, and I will try that tomorrow.

Yes, you could. But I still think you're right about the requiring only a 206.

How about this patch?

--- lib/transfer.c 26 Feb 2007 04:24:29 -0000 1.339
+++ lib/transfer.c 3 Mar 2007 21:47:05 -0000
@@ -1147,7 +1147,7 @@
                  k->ignorebody = TRUE;
                  infof(data, "Ignoring the response-body\n");
                }
- if (data->reqdata.resume_from && !k->content_range &&
+ if (data->reqdata.resume_from && (k->httpcode != 206) &&
                    (data->set.httpreq==HTTPREQ_GET) &&
                    !k->ignorebody) {
                  /* we wanted to resume a download, although the server doesn't

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2007-03-03