qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-img / curl: When fetching Content-Size use GET instead of HEAD.
@ 2015-12-07 21:23 Boris Schrijver
  2015-12-08 19:40 ` [Qemu-devel] [Qemu-block] " John Snow
  2015-12-08 19:56 ` [Qemu-devel] " Michael Tokarev
  0 siblings, 2 replies; 10+ messages in thread
From: Boris Schrijver @ 2015-12-07 21:23 UTC (permalink / raw)
  To: qemu-devel, jcody, kwolf, qemu-block; +Cc: Wido Hollander

Hi all,

I was testing out the "qemu-img info/convert" options in combination with
"http/https" when I stumbled upon this issue. When "qemu-img info/convert" tries
to collect the file info it will first try to fetch the Content-Size of the
remote file. It does a HEAD request and after a GET request for the correct
range.

The HEAD request is an issue. Because when you've got a pre-signed url, for
example from S3, which INCLUDES the REQUEST METHOD in it's signature, you'll get
a 403 Forbidden.

It's is therefore better to use only the GET request method, and discard the
body at the first call.

Please review! I'll be ready for answers!

[PATCH] 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.
---
 block/curl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/curl.c b/block/curl.c
index 8994182..2e74c32 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -594,11 +594,11 @@ static int curl_open(BlockDriverState *bs, QDict *options,
int flags,
     // Get file size
 
     s->accept_range = false;
-    curl_easy_setopt(state->curl, CURLOPT_NOBODY, 1);
+    curl_easy_setopt(state->curl, CURLOPT_HTTPGET, 1);
     curl_easy_setopt(state->curl, CURLOPT_HEADERFUNCTION,
                      curl_header_cb);
     curl_easy_setopt(state->curl, CURLOPT_HEADERDATA, s);
-    if (curl_easy_perform(state->curl))
+    if (curl_easy_perform(state->curl) != 23)
         goto out;
     curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d);
     if (d)
-- 
2.1.4

-- 

Met vriendelijke groet / Kind regards,

Boris Schrijver

PCextreme B.V.

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread
[parent not found: <1449823245-4951-1-git-send-email-boris@pcextreme.nl>]

end of thread, other threads:[~2015-12-11 13:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-07 21:23 [Qemu-devel] [PATCH] qemu-img / curl: When fetching Content-Size use GET instead of HEAD Boris Schrijver
2015-12-08 19:40 ` [Qemu-devel] [Qemu-block] " John Snow
2015-12-08 20:49   ` Boris Schrijver
2015-12-10 21:26     ` John Snow
2015-12-10 21:29       ` Boris Schrijver
2015-12-08 19:56 ` [Qemu-devel] " Michael Tokarev
2015-12-08 20:39   ` Boris Schrijver
2015-12-09 22:37   ` [Qemu-devel] [PATCH v2] " Boris Schrijver
2015-12-10 22:21     ` [Qemu-devel] [Qemu-block] " John Snow
     [not found] <1449823245-4951-1-git-send-email-boris@pcextreme.nl>
2015-12-11 13:54 ` [Qemu-devel] [Qemu-block] [PATCH V2] " Eric Blake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).