HTTPDownloader: Pass content type by reference

This commit is contained in:
Connor McLaughlin 2022-09-18 16:02:43 +10:00 committed by refractionpcsx2
parent 99fbe4e9ff
commit 9c64193434
4 changed files with 6 additions and 6 deletions

View File

@ -118,7 +118,7 @@ void HTTPDownloader::LockedPollRequests(std::unique_lock<std::mutex>& lock)
m_pending_http_requests.erase(m_pending_http_requests.begin() + index);
lock.unlock();
req->callback(-1, std::string(), Request::Data());
req->callback(-1, req->content_type, Request::Data());
CloseRequest(req);
@ -140,7 +140,7 @@ void HTTPDownloader::LockedPollRequests(std::unique_lock<std::mutex>& lock)
// run callback with lock unheld
lock.unlock();
req->callback(req->status_code, std::move(req->content_type), std::move(req->data));
req->callback(req->status_code, req->content_type, std::move(req->data));
CloseRequest(req);
lock.lock();
}

View File

@ -36,7 +36,7 @@ namespace Common
struct Request
{
using Data = std::vector<u8>;
using Callback = std::function<void(s32 status_code, std::string content_type, Data data)>;
using Callback = std::function<void(s32 status_code, const std::string& content_type, Data data)>;
enum class Type
{

View File

@ -259,7 +259,7 @@ bool HTTPDownloaderWinHttp::StartRequest(HTTPDownloader::Request* request)
if (!WinHttpCrackUrl(url_wide.c_str(), static_cast<DWORD>(url_wide.size()), 0, &uc))
{
Console.Error("WinHttpCrackUrl() failed: %u", GetLastError());
req->callback(-1, std::string(), Request::Data());
req->callback(-1, req->content_type, Request::Data());
delete req;
return false;
}
@ -271,7 +271,7 @@ bool HTTPDownloaderWinHttp::StartRequest(HTTPDownloader::Request* request)
if (!req->hConnection)
{
Console.Error("Failed to start HTTP request for '%s': %u", req->url.c_str(), GetLastError());
req->callback(-1, std::string(), Request::Data());
req->callback(-1, req->content_type, Request::Data());
delete req;
return false;
}

View File

@ -885,7 +885,7 @@ bool GameList::DownloadCovers(const std::vector<std::string>& url_templates, boo
// we could actually do a few in parallel here...
std::string filename(Common::HTTPDownloader::URLDecode(url));
downloader->CreateRequest(std::move(url), [use_serial, &save_callback, entry_path = std::move(entry_path),
filename = std::move(filename)](s32 status_code, std::string content_type, Common::HTTPDownloader::Request::Data data) {
filename = std::move(filename)](s32 status_code, const std::string& content_type, Common::HTTPDownloader::Request::Data data) {
if (status_code != Common::HTTPDownloader::HTTP_OK || data.empty())
return;