mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
http: Set a more useful user agent.
This commit is contained in:
parent
e2e1c677cb
commit
a35b21a5d7
7 changed files with 19 additions and 4 deletions
|
@ -22,6 +22,8 @@ bool LoadRemoteFileList(const std::string &url, bool *cancel, std::vector<File::
|
|||
int code = 500;
|
||||
std::vector<std::string> responseHeaders;
|
||||
|
||||
http.SetUserAgent(StringFromFormat("PPSSPP/%s", PPSSPP_GIT_VERSION));
|
||||
|
||||
Url baseURL(url);
|
||||
if (!baseURL.Valid()) {
|
||||
return false;
|
||||
|
|
|
@ -181,11 +181,11 @@ void Connection::Disconnect() {
|
|||
namespace http {
|
||||
|
||||
// TODO: do something sane here
|
||||
#define USERAGENT "NATIVEAPP 1.0"
|
||||
constexpr const char *DEFAULT_USERAGENT = "NATIVEAPP 1.0";
|
||||
|
||||
Client::Client() {
|
||||
httpVersion_ = "1.1";
|
||||
userAgent_ = USERAGENT;
|
||||
userAgent_ = DEFAULT_USERAGENT;
|
||||
}
|
||||
|
||||
Client::~Client() {
|
||||
|
@ -323,7 +323,7 @@ int Client::SendRequestWithData(const char *method, const char *resource, const
|
|||
buffer.Printf(tpl,
|
||||
method, resource, httpVersion_,
|
||||
host_.c_str(),
|
||||
userAgent_,
|
||||
userAgent_.c_str(),
|
||||
otherHeaders ? otherHeaders : "");
|
||||
buffer.Append(data);
|
||||
bool flushed = buffer.FlushSocket(sock(), dataTimeout_);
|
||||
|
|
|
@ -69,8 +69,12 @@ public:
|
|||
dataTimeout_ = t;
|
||||
}
|
||||
|
||||
void SetUserAgent(const std::string &&value) {
|
||||
userAgent_ = value;
|
||||
}
|
||||
|
||||
protected:
|
||||
const char *userAgent_;
|
||||
std::string userAgent_;
|
||||
const char *httpVersion_;
|
||||
double dataTimeout_ = -1.0;
|
||||
};
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "Common/Common.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/FileLoaders/HTTPFileLoader.h"
|
||||
|
||||
HTTPFileLoader::HTTPFileLoader(const std::string &filename)
|
||||
|
@ -28,6 +29,8 @@ HTTPFileLoader::HTTPFileLoader(const std::string &filename)
|
|||
|
||||
void HTTPFileLoader::Prepare() {
|
||||
std::call_once(preparedFlag_, [this](){
|
||||
client_.SetUserAgent(StringFromFormat("PPSSPP/%s", PPSSPP_GIT_VERSION));
|
||||
|
||||
std::vector<std::string> responseHeaders;
|
||||
Url resourceURL = url_;
|
||||
int redirectsLeft = 20;
|
||||
|
|
|
@ -263,6 +263,8 @@ namespace Reporting
|
|||
http::Client http;
|
||||
Buffer theVoid;
|
||||
|
||||
http.SetUserAgent(StringFromFormat("PPSSPP/%s", PPSSPP_GIT_VERSION));
|
||||
|
||||
if (output == NULL)
|
||||
output = &theVoid;
|
||||
|
||||
|
|
|
@ -65,6 +65,8 @@ static bool RegisterServer(int port) {
|
|||
http::Client http;
|
||||
Buffer theVoid;
|
||||
|
||||
http.SetUserAgent(StringFromFormat("PPSSPP/%s", PPSSPP_GIT_VERSION));
|
||||
|
||||
char resource4[1024] = {};
|
||||
if (http.Resolve(REPORT_HOSTNAME, REPORT_PORT, net::DNSType::IPV4)) {
|
||||
if (http.Connect()) {
|
||||
|
|
|
@ -117,6 +117,8 @@ bool RemoteISOConnectScreen::FindServer(std::string &resultHost, int &resultPort
|
|||
statusMessage_ = formatted;
|
||||
};
|
||||
|
||||
http.SetUserAgent(StringFromFormat("PPSSPP/%s", PPSSPP_GIT_VERSION));
|
||||
|
||||
auto TryServer = [&](const std::string &host, int port) {
|
||||
SetStatus("Resolving [URL]...", host, port);
|
||||
if (!http.Resolve(host.c_str(), port)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue