mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Added a User-Agent string when making non-scraper HTTP requests
This commit is contained in:
parent
a021fc22a9
commit
47baa3629a
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "HttpReq.h"
|
#include "HttpReq.h"
|
||||||
|
|
||||||
|
#include "ApplicationVersion.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "resources/ResourceManager.h"
|
#include "resources/ResourceManager.h"
|
||||||
|
@ -80,6 +81,32 @@ HttpReq::HttpReq(const std::string& url, bool scraperRequest)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mScraperRequest) {
|
||||||
|
// Set User-Agent.
|
||||||
|
std::string userAgent {"ES-DE Frontend/"};
|
||||||
|
userAgent.append(PROGRAM_VERSION_STRING).append(" (");
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
userAgent.append("Android");
|
||||||
|
#elif defined(_WIN64)
|
||||||
|
userAgent.append("Windows");
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
userAgent.append("macOS");
|
||||||
|
#elif defined(__linux__)
|
||||||
|
userAgent.append("Linux");
|
||||||
|
#elif defined(__unix__)
|
||||||
|
userAgent.append("Unix");
|
||||||
|
#else
|
||||||
|
userAgent.append("Unknown");
|
||||||
|
#endif
|
||||||
|
userAgent.append(")");
|
||||||
|
CURLcode err {curl_easy_setopt(mHandle, CURLOPT_USERAGENT, userAgent.c_str())};
|
||||||
|
if (err != CURLE_OK) {
|
||||||
|
mStatus = REQ_IO_ERROR;
|
||||||
|
onError(curl_easy_strerror(err));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
long connectionTimeout;
|
long connectionTimeout;
|
||||||
|
|
||||||
if (mScraperRequest) {
|
if (mScraperRequest) {
|
||||||
|
|
Loading…
Reference in a new issue