diff --git a/Common/Net/HTTPClient.cpp b/Common/Net/HTTPClient.cpp index 2596b7dd3c..bbc8e09c75 100644 --- a/Common/Net/HTTPClient.cpp +++ b/Common/Net/HTTPClient.cpp @@ -229,8 +229,6 @@ Client::~Client() { Disconnect(); } -// Ignores line folding (deprecated), but respects field combining. -// Don't use for Set-Cookie, which is a special header per RFC 7230. bool GetHeaderValue(const std::vector &responseHeaders, std::string_view header, std::string *value) { std::string search(header); search.push_back(':'); @@ -317,7 +315,7 @@ int Client::POST(const RequestParams &req, std::string_view data, std::string_vi if (mime.empty()) { snprintf(otherHeaders, sizeof(otherHeaders), "Content-Length: %lld\r\n", (long long)data.size()); } else { - snprintf(otherHeaders, sizeof(otherHeaders), "Content-Length: %lld\r\nContent-Type: %.*s\r\n", (long long)data.size(), (int)mime.size(), mime.data()); + snprintf(otherHeaders, sizeof(otherHeaders), "Content-Length: %lld\r\nContent-Type: %.*s\r\n", (long long)data.size(), STR_VIEW(mime)); } int err = SendRequestWithData("POST", req, data, otherHeaders, progress); @@ -514,8 +512,7 @@ int Client::ReadResponseEntity(net::Buffer *readbuf, const std::vector &responseHeaders, std::string_view header, std::string *value); class RequestParams { @@ -132,7 +134,7 @@ private: 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) + : Request(method, url, name, Path(), cancelled, flags) { buffer_.Append(responseData); } diff --git a/Common/Net/HTTPNaettRequest.cpp b/Common/Net/HTTPNaettRequest.cpp index da7189e195..516a944045 100644 --- a/Common/Net/HTTPNaettRequest.cpp +++ b/Common/Net/HTTPNaettRequest.cpp @@ -13,8 +13,7 @@ namespace http { 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; + : Request(method, url, name, outfile, &cancelled_, flags), postData_(postData), postMime_(postMime) { } HTTPSRequest::~HTTPSRequest() { @@ -61,7 +60,7 @@ void HTTPSRequest::Join() { res_ = nullptr; req_ = nullptr; } else { - ERROR_LOG(Log::HTTP, "HTTPSDownload::Join not implemented"); + ERROR_LOG(Log::HTTP, "HTTPSRequest::Join called before completion"); } } diff --git a/Common/Net/HTTPNaettRequest.h b/Common/Net/HTTPNaettRequest.h index 3ff7e5e1b0..71054d8a21 100644 --- a/Common/Net/HTTPNaettRequest.h +++ b/Common/Net/HTTPNaettRequest.h @@ -25,7 +25,6 @@ public: bool Failed() const override { return failed_; } private: - RequestMethod method_; std::string postData_; std::string postMime_; bool completed_ = false; diff --git a/Common/Net/HTTPRequest.cpp b/Common/Net/HTTPRequest.cpp index 1dd8d06027..b41d18c093 100644 --- a/Common/Net/HTTPRequest.cpp +++ b/Common/Net/HTTPRequest.cpp @@ -10,8 +10,8 @@ namespace http { -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) { +Request::Request(RequestMethod method, std::string_view url, std::string_view name, const Path &outFile, bool *cancelled, RequestFlags flags) + : method_(method), url_(url), name_(name), outfile_(outFile), 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 = [this](int64_t bytes, int64_t contentLength, bool done) { diff --git a/Common/Net/HTTPRequest.h b/Common/Net/HTTPRequest.h index 0c2e80568f..29991b49ac 100644 --- a/Common/Net/HTTPRequest.h +++ b/Common/Net/HTTPRequest.h @@ -31,7 +31,7 @@ using RequestCompletionCallback = std::function; // Abstract request. class Request { public: - Request(RequestMethod method, std::string_view url, std::string_view name, bool *cancelled, RequestFlags mode); + Request(RequestMethod method, std::string_view url, std::string_view name, const Path &outFile, bool *cancelled, RequestFlags mode); virtual ~Request() {} void SetAccept(const char *mime) {