curl-users
Re: libcurl - sample code for multiple out of order range requests from same url
Date: Mon, 31 Jul 2017 12:18:45 +0100
Thanks Ray. I got something working that will do for now but not a fan
of the non-deterministic nature of range request responses.
Realize this is an http standards committee issue rather than anything
curl specific. curl handles the protocol as best it can.
Cheers,
Steve.
On 29/07/17 08:20, Ray Satiro via curl-users wrote:
> On 7/27/2017 7:57 AM, Steve Williams wrote:
>> To reply to my own query - have worked this a little further &
>> figured out how to determine the range a write callback refers to -
>> by adding a header callback and pulling the information from the
>> relevant header line.
>>
>> Current issue is getting http range requests to do what I want. Seems
>> the spec allows servers to second guess and deliver more than was
>> requested which is *so* annoying. Almost annoying enough to drop back
>> to sockets and write my own protocol that delivers what I actually
>> asked for :)
>>
>> Any insight into how to get range requests to perform more
>> deterministically would be appreciated.
>
> AFAIK if you make a range request for a single part per request and
> you get 206 in reply then that will be the content you requested, but
> yes 206 is not guaranteed. If you make a request for multiple parts
> per request then detecting that all the parts are fulfilled will be
> complicated based on my reading of RFC 7233 [1]. Offhand I don't know
> if libcurl handles that. If you are requesting a single part in each
> request you could test for 206 in the write callback instead of
> parsing the Content-Range header.
>
> size_t realsize = size * nmemb;
> ...
> if(user->range) {
> long response_code = 0;
> curl_easy_getinfo(user->curl_handle, CURLINFO_RESPONSE_CODE,
> &response_code);
> /* don't write server responses other than 206 partial */
> if(response_code != 206)
> return realsize;
> }
> write here
>
> You can pass a user pointer to the write callback by using
> CURLOPT_WRITEDATA [2].
>
> RTSP ranging is different, hopefully someone experienced with it can
> chime in.
>
> [1]: https://tools.ietf.org/html/rfc7233#page-10
> [2]: https://curl.haxx.se/libcurl/c/CURLOPT_WRITEDATA.html
>
>
>
> -----------------------------------------------------------
> Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
> Etiquette: https://curl.haxx.se/mail/etiquette.html
-- Best regards, Steve Williams Managing Director Advance Software Limited Mobile: +44 (0)745 9344854 Skype: steve--w <><> Infinity is here... Get your free 3D web browser today : http://advance-software.com/products How does your organisation plan to exploit the virtual reality opportunity ? Visit our 3D web portal : http://infinity-online.net https://www.facebook.com/advance.sw Twitter : @AdvanceSoftware https://www.linkedin.com/in/advsw
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-07-31