mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-08 11:55:24 +00:00
fetchurl: User-Agent header and HTTP response code
I discovered thinkbroadband.com requires the User-Agent header field and rejects requests missing it with HTTP response code 403 "access to the requested resource is forbidden". Now, fetchurl always adds the User-Agent header fetchurl/LIBCURL_VERSION. Also the error message now contains the HTTP response code.
This commit is contained in:
parent
b16bb82f8b
commit
119d72ad94
@ -276,12 +276,17 @@ struct Fetchurl::Main
|
||||
curl_easy_setopt(_curl, CURLOPT_PROXY, _fetch.proxy.string());
|
||||
}
|
||||
|
||||
curl_easy_setopt(_curl, CURLOPT_USERAGENT, "fetchurl/" LIBCURL_VERSION);
|
||||
|
||||
CURLcode res = curl_easy_perform(_curl);
|
||||
close(_fetch.fd);
|
||||
_fetch.fd = -1;
|
||||
|
||||
if (res != CURLE_OK)
|
||||
Genode::error(curl_easy_strerror(res), ", failed to fetch ", _fetch.url);
|
||||
if (res != CURLE_OK) {
|
||||
unsigned long response_code = -1;
|
||||
curl_easy_getinfo(_curl, CURLINFO_RESPONSE_CODE, &response_code);
|
||||
Genode::error(curl_easy_strerror(res), " (code=", response_code, "), failed to fetch ", _fetch.url);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user