Dear Daniel,

Using --libcurl test.c helped out a lot! Thanks!

It showed me that I could use an option I wasn't aware of [1]. In combination
with [2] it got me what I wanted!

I would like to thank you for responding so promptly!


[1] curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
[2] curl_easy_setopt(hnd, CURLOPT_NOBODY, 1L);

-- 

Met vriendelijke groet / Kind regards,

Boris Schrijver

PCextreme B.V.

http://www.pcextreme.nl/contact
Tel direct: +31 (0) 118 700 215

> On December 9, 2015 at 11:10 PM Daniel Stenberg <[email protected]> wrote:
> 
> 
> On Wed, 9 Dec 2015, Boris Schrijver wrote:
> 
> > What I basically want is: curl -X GET -I http://random.url/object
> 
> Append "--libcurl test.c" on that command line and you'll see how to write 
> code for it. Although I suspect you may confuse libcurl a bit by doing that so
> 
> the next request on the same connection will probably first have to detect 
> that there's pending data which will make think it died, then close the 
> connection and create a new one.
> 
> > I tried to implement it in qemu-img [2] but ended up always getting a
> > CURLE_WRITE_ERROR, due to the body not being written anywhere.
> 
> That's because you cut off the response and that makes it a transfer error. 
> There's no way around that.
> 
> But you can easily set a flag or something before you return that error that 
> cuts off the body, and then when you see CURLE_WRITE_ERROR you check if that 
> flag was set and then you know it was on purpose. Done!
> 
> > Is it possible to include a curl_easy_setopt() option to discard the
> > response
> > body and stop the connection after the HEADER?
> 
> Nope. And I don't see the point in adding such an option either, as you can 
> easily implement this yourself as described above.
> 
> -- 
> 
>   / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette:  http://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to