block/curl: set User-Agent header
Some HTTP servers and WAFs (e.g. Amazon CloudFront) reject requests without a User-Agent header with 403 Forbidden. This makes qemu-img info and other curl-based operations fail on such URLs without any obvious indication of the root cause. Set a "QEMU/<version>" User-Agent string on all curl handles to ensure compatibility with these endpoints. Signed-off-by: Vladimir Lobanov <lobanov-vla@yandex.ru> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
1 parent
dacbde0ad7
commit
68dd6989ab
1 file changed
+2
@@ -482,6 +482,8 @@ static int curl_init_state(BDRVCURLState *s, CURLState *state)
|
||||
}
|
||||
}
|
||||
if (curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, (long)s->timeout) ||
|
||||
curl_easy_setopt(state->curl, CURLOPT_USERAGENT,
|
||||
"QEMU/" QEMU_VERSION) ||
|
||||
curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION,
|
||||
(void *)curl_read_cb) ||
|
||||
curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state) ||
|
||||
|
||||
Reference in new issue
Block a user