qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] qemu-img / curl: When fetching Content-Size


From: Boris Schrijver
Subject: Re: [Qemu-devel] [PATCH v2] qemu-img / curl: When fetching Content-Size use GET instead of HEAD.
Date: Wed, 9 Dec 2015 23:37:48 +0100 (CET)

Dear all,

Thanks for your time so-far.

I send a mail to the libcurl development list and got a helpful reaction [1]! I
changed my patch accordingly. We now don't have to check for a CURLE_WRITE_ERROR
anymore and curl_easy_perform() will return CURLE_OK (0) on success.

Please review!

commit c5588e94f5f0e66636b16a4ee26f0dbcf48b44c9
Author: Boris Schrijver <address@hidden>
Date:   Wed Dec 9 23:32:36 2015 +0100

    qemu-img / curl: When fetching Content-Size use GET instead of HEAD.
    
    A server can respond different to both methods, or can block one of the two.
    
    Signed-off-by: Boris Schrijver <address@hidden>

diff --git a/block/curl.c b/block/curl.c
index 8994182..1677d0c 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -598,6 +598,7 @@ static int curl_open(BlockDriverState *bs, QDict *options,
int flags,
     curl_easy_setopt(state->curl, CURLOPT_HEADERFUNCTION,
                      curl_header_cb);
     curl_easy_setopt(state->curl, CURLOPT_HEADERDATA, s);
+    curl_easy_setopt(state->curl, CURLOPT_CUSTOMREQUEST, "GET");
     if (curl_easy_perform(state->curl))
         goto out;
     curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d);



[1] http://curl.haxx.se/mail/lib-2015-12/0041.html

-- 

Met vriendelijke groet / Kind regards,

Boris Schrijver

PCextreme B.V.

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

> On December 8, 2015 at 8:56 PM Michael Tokarev <address@hidden> wrote:
> 
> 
> 08.12.2015 00:23, Boris Schrijver wrote:
> []
> > It's is therefore better to use only the GET request method, and discard the
> > body at the first call.
> 
> Nooooooo!  Please NOOOO!
> 
> Fetching a large file once might be too long already.
> Fetching it twice is twice as long.  Oh well!..
> 
> Thanks,
> 
> /mjt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]