mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Add fake request class for cached responses.
This commit is contained in:
1 parent
c3cc3da8fe
commit
e4d08407ab
6 files changed
+23
-9
No files matched your search
@@ -486,8 +486,8 @@ int Client::ReadResponseEntity(net::Buffer *readbuf, const std::vector<std::stri
|
||||
return 0;
|
||||
}
|
||||
|
||||
HTTPRequest::HTTPRequest(RequestMethod method, std::string_view url, std::string_view postData, std::string_view postMime, const Path &outfile, RequestFlags progressBarMode, std::string_view name)
|
||||
: Request(method, url, name, &cancelled_, progressBarMode), postData_(postData), postMime_(postMime) {
|
||||
HTTPRequest::HTTPRequest(RequestMethod method, std::string_view url, std::string_view postData, std::string_view postMime, const Path &outfile, RequestFlags flags, std::string_view name)
|
||||
: Request(method, url, name, &cancelled_, flags), postData_(postData), postMime_(postMime) {
|
||||
outfile_ = outfile;
|
||||
}
|
||||
|
||||
|
||||
+15
-1
@@ -96,7 +96,7 @@ protected:
|
||||
// Really an asynchronous request.
|
||||
class HTTPRequest : public Request {
|
||||
public:
|
||||
HTTPRequest(RequestMethod method, std::string_view url, std::string_view postData, std::string_view postMime, const Path &outfile, RequestFlags progressBarMode = RequestFlags::ProgressBar | RequestFlags::ProgressBarDelayed, std::string_view name = "");
|
||||
HTTPRequest(RequestMethod method, std::string_view url, std::string_view postData, std::string_view postMime, const Path &outfile, RequestFlags flags = RequestFlags::ProgressBar | RequestFlags::ProgressBarDelayed, std::string_view name = "");
|
||||
~HTTPRequest();
|
||||
|
||||
void Start() override;
|
||||
@@ -119,4 +119,18 @@ private:
|
||||
bool joined_ = false;
|
||||
};
|
||||
|
||||
// Fake request for cache hits.
|
||||
class CachedRequest : public Request {
|
||||
public:
|
||||
CachedRequest(RequestMethod method, std::string_view url, std::string_view name, bool *cancelled, RequestFlags flags, std::string_view responseData)
|
||||
: Request(method, url, name, cancelled, flags)
|
||||
{
|
||||
buffer_.Append(responseData);
|
||||
}
|
||||
void Start() override {}
|
||||
void Join() override {}
|
||||
bool Done() override { return true; }
|
||||
bool Failed() const override { return false; }
|
||||
};
|
||||
|
||||
} // namespace http
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
namespace http {
|
||||
|
||||
HTTPSRequest::HTTPSRequest(RequestMethod method, std::string_view url, std::string_view postData, std::string_view postMime, const Path &outfile, RequestFlags progressBarMode, std::string_view name)
|
||||
: Request(method, url, name, &cancelled_, progressBarMode), method_(method), postData_(postData), postMime_(postMime) {
|
||||
HTTPSRequest::HTTPSRequest(RequestMethod method, std::string_view url, std::string_view postData, std::string_view postMime, const Path &outfile, RequestFlags flags, std::string_view name)
|
||||
: Request(method, url, name, &cancelled_, flags), method_(method), postData_(postData), postMime_(postMime) {
|
||||
outfile_ = outfile;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace http {
|
||||
// Really an asynchronous request.
|
||||
class HTTPSRequest : public Request {
|
||||
public:
|
||||
HTTPSRequest(RequestMethod method, std::string_view url, std::string_view postData, std::string_view postMime, const Path &outfile, RequestFlags progressBarMode = RequestFlags::ProgressBar | RequestFlags::ProgressBarDelayed, std::string_view name = "");
|
||||
HTTPSRequest(RequestMethod method, std::string_view url, std::string_view postData, std::string_view postMime, const Path &outfile, RequestFlags flags = RequestFlags::ProgressBar | RequestFlags::ProgressBarDelayed, std::string_view name = "");
|
||||
~HTTPSRequest();
|
||||
|
||||
void Start() override;
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
namespace http {
|
||||
|
||||
Request::Request(RequestMethod method, std::string_view url, std::string_view name, bool *cancelled, RequestFlags mode)
|
||||
: method_(method), url_(url), name_(name), progress_(cancelled), flags_(mode) {
|
||||
Request::Request(RequestMethod method, std::string_view url, std::string_view name, bool *cancelled, RequestFlags flags)
|
||||
: method_(method), url_(url), name_(name), progress_(cancelled), flags_(flags) {
|
||||
INFO_LOG(Log::HTTP, "HTTP %s request: %.*s (%.*s)", RequestMethodToString(method), (int)url.size(), url.data(), (int)name.size(), name.data());
|
||||
|
||||
progress_.callback = [=](int64_t bytes, int64_t contentLength, bool done) {
|
||||
|
||||
+1
-1
@@ -328,7 +328,7 @@ void StartInfraJsonDownload() {
|
||||
INFO_LOG(Log::sceNet, "json is already being downloaded");
|
||||
}
|
||||
const char *acceptMime = "application/json, text/*; q=0.9, */*; q=0.8";
|
||||
g_infraDL = g_DownloadManager.StartDownload("http://metadata.ppsspp.org/infra-dns.json", Path(), http::ProgressBarMode::NONE, acceptMime);
|
||||
g_infraDL = g_DownloadManager.StartDownload("http://metadata.ppsspp.org/infra-dns.json", Path(), http::RequestFlags::Default, acceptMime);
|
||||
}
|
||||
|
||||
bool PollInfraJsonDownload(std::string *jsonOutput) {
|
||||
|
||||
Reference in new issue
Block a user