From 8ad8048345fb09ad5243fed651b9645d1343fa15 Mon Sep 17 00:00:00 2001 From: Tindy X <49061470+tindy2013@users.noreply.github.com> Date: Mon, 29 Jun 2020 00:12:24 +0800 Subject: [PATCH] Fix User-Agent header not being correctly sent while fetching files --- src/webget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/webget.cpp b/src/webget.cpp index 614c8d9..1a0f8ef 100644 --- a/src/webget.cpp +++ b/src/webget.cpp @@ -104,7 +104,10 @@ static int curlGet(const FetchArgument argument, FetchResult &result) if(argument.request_headers) { for(auto &x : *argument.request_headers) - list = curl_slist_append(list, (x.first + ": " + x.second).data()); + { + if(toLower(x.first) != "user-agent") + list = curl_slist_append(list, (x.first + ": " + x.second).data()); + } } if(list) curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, list); @@ -252,7 +255,6 @@ int curlPost(const std::string &url, const std::string &data, const std::string curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writer); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, retData); curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, list); - curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, user_agent_str.data()); if(proxy.size()) curl_easy_setopt(curl_handle, CURLOPT_PROXY, proxy.data()); @@ -296,7 +298,6 @@ int curlPatch(const std::string &url, const std::string &data, const std::string curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writer); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, retData); curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, list); - curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, user_agent_str.data()); if(proxy.size()) curl_easy_setopt(curl_handle, CURLOPT_PROXY, proxy.data()); @@ -337,7 +338,6 @@ int curlHead(const std::string &url, const std::string &proxy, const string_arra curl_easy_setopt(curl_handle, CURLOPT_HEADERDATA, &response_headers); curl_easy_setopt(curl_handle, CURLOPT_NOBODY, 1L); curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, list); - curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, user_agent_str.data()); if(proxy.size()) curl_easy_setopt(curl_handle, CURLOPT_PROXY, proxy.data());