Hi folks, I’m trying to PUT a sub-interval of a file. In simple terms, for the sake of example, let’s say I have a 4-byte file and I want to PUT the middle two bytes.
Here’s what I expect the headers to look like: Content-Range: 1-2/4 Content-Length: 2 I’m having trouble telling libcurl to do that. Here’s what I tried: If I set CURLOPT_RANGE to 1-2 and CURLOPT_INFILESIZE to 4, then I get Content-Range 1-2/4, but Content-Length is set to 4 instead of the desired 2. If I set CURLOPT_RANGE to 1-2 and CURLOPT_INFILESIZE to 2, then I get Content-Length 2, but Content-Range is set to 1-2/2 instead of 1-2/4. If I set CURLOPT_RESUME_FROM to 1 and CURLOPT_INFILESIZE to 4, then I get Content-Range 1-3/4 and Content-Length 3, which are sane relative to each other but go all the way to EOF rather than stopping where I want to. If I set CURLOPT_RESUME_FROM to 1 and CURLOPT_INFILESIZE to 3, then I get Content-Range: 1-2/3 and Content-Length 2, which is the right range and length but the wrong total file size (Content-Range should be 1-2/4). If I set both CURLOPT_RESUME_FROM and CURLOPT_RANGE, the latter seems to be completely ignored. Right now I’m thinking of just setting CURLOPT_INFILESIZE to 2 and CURLOPT_HTTPHEADER to Content-Range:1-2/4, but I would like to know if I’m missing something and maybe there is a way to make libcurl do this “properly” rather than manually constructing the header? Thanks all! -- Christopher Head
pgpNfPomcqeLL.pgp
Description: OpenPGP digital signature
------------------------------------------------------------------- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.html