diff --git a/Common/Net/HTTPClient.cpp b/Common/Net/HTTPClient.cpp index 82865e3410..f1831ce297 100644 --- a/Common/Net/HTTPClient.cpp +++ b/Common/Net/HTTPClient.cpp @@ -458,8 +458,8 @@ int Client::ReadResponseEntity(net::Buffer *readbuf, const std::vector Downloader::StartDownload(const std::string &url, const Path &outfile, const char *acceptMime) { - std::shared_ptr dl(new Download(RequestMethod::GET, url, "", outfile)); + std::shared_ptr dl(new Download(RequestMethod::GET, url, "", "", outfile)); if (acceptMime) dl->SetAccept(acceptMime); downloads_.push_back(dl); @@ -588,7 +592,7 @@ std::shared_ptr Downloader::StartDownloadWithCallback( const Path &outfile, std::function callback, const char *acceptMime) { - std::shared_ptr dl(new Download(RequestMethod::GET, url, "", outfile)); + std::shared_ptr dl(new Download(RequestMethod::GET, url, "", "", outfile)); if (acceptMime) dl->SetAccept(acceptMime); dl->SetCallback(callback); @@ -601,7 +605,8 @@ std::shared_ptr Downloader::AsyncPostWithCallback( const std::string &url, const std::string &postData, std::function callback) { - std::shared_ptr dl(new Download(RequestMethod::POST, url, postData, Path())); + std::string postMime = "application/x-www-form-urlencoded"; + std::shared_ptr dl(new Download(RequestMethod::POST, url, postData, postMime, Path())); dl->SetCallback(callback); downloads_.push_back(dl); dl->Start(); @@ -624,6 +629,7 @@ void Downloader::Update() { void Downloader::WaitForAll() { // TODO: Should lock? Though, OK if called from main thread, where Update() is called from. while (!downloads_.empty()) { + Update(); sleep_ms(10); } } diff --git a/Common/Net/HTTPClient.h b/Common/Net/HTTPClient.h index d156a18301..0aeab09472 100644 --- a/Common/Net/HTTPClient.h +++ b/Common/Net/HTTPClient.h @@ -105,7 +105,8 @@ enum class RequestMethod { // Really an asynchronous request. class Download { public: - Download(RequestMethod method, const std::string &url, const std::string &postData, const Path &outfile); + // postMime should often be "application/x-www-form-urlencoded"; + Download(RequestMethod method, const std::string &url, const std::string &postData, const std::string &postMime, const Path &outfile); ~Download(); void Start(); @@ -172,6 +173,7 @@ private: Path outfile_; std::thread thread_; const char *acceptMime_ = "*/*"; + std::string postMime_; int resultCode_ = 0; bool completed_ = false; bool failed_ = false;