From 601e767e3b2a32c71fbe9fa0b95b856daaf8ad39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 17 Jun 2023 22:29:32 +0200 Subject: [PATCH 1/6] HTTPClient: Generalize Download to support GET and POST --- Common/Net/HTTPClient.cpp | 30 ++++++++++++++++++++++++------ Common/Net/HTTPClient.h | 20 +++++++++++++++++--- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/Common/Net/HTTPClient.cpp b/Common/Net/HTTPClient.cpp index 7ef0c15df1b0..82865e3410ae 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(url, outfile)); + std::shared_ptr dl(new Download(RequestMethod::GET, url, "", outfile)); if (acceptMime) dl->SetAccept(acceptMime); downloads_.push_back(dl); @@ -588,7 +588,7 @@ std::shared_ptr Downloader::StartDownloadWithCallback( const Path &outfile, std::function callback, const char *acceptMime) { - std::shared_ptr dl(new Download(url, outfile)); + std::shared_ptr dl(new Download(RequestMethod::GET, url, "", outfile)); if (acceptMime) dl->SetAccept(acceptMime); dl->SetCallback(callback); @@ -597,6 +597,17 @@ std::shared_ptr Downloader::StartDownloadWithCallback( return dl; } +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())); + dl->SetCallback(callback); + downloads_.push_back(dl); + dl->Start(); + return dl; +} + void Downloader::Update() { restart: for (size_t i = 0; i < downloads_.size(); i++) { @@ -610,6 +621,13 @@ void Downloader::Update() { } } +void Downloader::WaitForAll() { + // TODO: Should lock? Though, OK if called from main thread, where Update() is called from. + while (!downloads_.empty()) { + sleep_ms(10); + } +} + std::vector Downloader::GetCurrentProgress() { std::vector progress; for (size_t i = 0; i < downloads_.size(); i++) { diff --git a/Common/Net/HTTPClient.h b/Common/Net/HTTPClient.h index cafe4b08c5bc..d156a1830189 100644 --- a/Common/Net/HTTPClient.h +++ b/Common/Net/HTTPClient.h @@ -97,10 +97,15 @@ class Client : public net::Connection { double dataTimeout_ = 900.0; }; -// Not particularly efficient, but hey - it's a background download, that's pretty cool :P +enum class RequestMethod { + GET, + POST, +}; + +// Really an asynchronous request. class Download { public: - Download(const std::string &url, const Path &outfile); + Download(RequestMethod method, const std::string &url, const std::string &postData, const Path &outfile); ~Download(); void Start(); @@ -154,11 +159,13 @@ class Download { private: void Do(); // Actually does the download. Runs on thread. - int PerformGET(const std::string &url); + int Perform(const std::string &url); std::string RedirectLocation(const std::string &baseUrl); void SetFailed(int code); RequestProgress progress_; + RequestMethod method_; + std::string postData_; Buffer buffer_; std::vector responseHeaders_; std::string url_; @@ -190,10 +197,17 @@ class Downloader { std::function callback, const char *acceptMime = nullptr); + std::shared_ptr AsyncPostWithCallback( + const std::string &url, + const std::string &postData, + std::function callback); + // Drops finished downloads from the list. void Update(); void CancelAll(); + void WaitForAll(); + std::vector GetCurrentProgress(); private: From 3bc2aaf7ca357e15ec309f5bb3a125994345ffce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 17 Jun 2023 22:31:01 +0200 Subject: [PATCH 2/6] Set MIME type "correctly" (at least for retro purposes) for POSTs --- Common/Net/HTTPClient.cpp | 22 ++++++++++++++-------- Common/Net/HTTPClient.h | 4 +++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Common/Net/HTTPClient.cpp b/Common/Net/HTTPClient.cpp index 82865e3410ae..f1831ce29791 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 d156a1830189..0aeab09472de 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 @@ class Download { Path outfile_; std::thread thread_; const char *acceptMime_ = "*/*"; + std::string postMime_; int resultCode_ = 0; bool completed_ = false; bool failed_ = false; From 71cb7663930af8792c12558b8e9f02a7ce145d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 17 Jun 2023 22:31:47 +0200 Subject: [PATCH 3/6] Fix re-entrancy issue in Downloader --- Common/Net/HTTPClient.cpp | 13 +++++++++---- Common/Net/HTTPClient.h | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Common/Net/HTTPClient.cpp b/Common/Net/HTTPClient.cpp index f1831ce29791..43b30f760264 100644 --- a/Common/Net/HTTPClient.cpp +++ b/Common/Net/HTTPClient.cpp @@ -582,7 +582,7 @@ std::shared_ptr Downloader::StartDownload(const std::string &url, cons std::shared_ptr dl(new Download(RequestMethod::GET, url, "", "", outfile)); if (acceptMime) dl->SetAccept(acceptMime); - downloads_.push_back(dl); + newDownloads_.push_back(dl); dl->Start(); return dl; } @@ -596,7 +596,7 @@ std::shared_ptr Downloader::StartDownloadWithCallback( if (acceptMime) dl->SetAccept(acceptMime); dl->SetCallback(callback); - downloads_.push_back(dl); + newDownloads_.push_back(dl); dl->Start(); return dl; } @@ -608,15 +608,20 @@ std::shared_ptr Downloader::AsyncPostWithCallback( 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); + newDownloads_.push_back(dl); dl->Start(); return dl; } void Downloader::Update() { + for (auto iter : newDownloads_) { + downloads_.push_back(iter); + } + newDownloads_.clear(); + restart: for (size_t i = 0; i < downloads_.size(); i++) { - auto &dl = downloads_[i]; + auto dl = downloads_[i]; if (dl->Done()) { dl->RunCallback(); dl->Join(); diff --git a/Common/Net/HTTPClient.h b/Common/Net/HTTPClient.h index 0aeab09472de..f6b832b834b9 100644 --- a/Common/Net/HTTPClient.h +++ b/Common/Net/HTTPClient.h @@ -214,6 +214,9 @@ class Downloader { private: std::vector> downloads_; + // These get copied to downloads_ in Update(). It's so that callbacks can add new downloads + // while running. + std::vector> newDownloads_; }; } // http From 2de510432df143d64ed80cf9b48d1f57812cb27b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 16 Jun 2023 12:40:10 +0200 Subject: [PATCH 4/6] Rename our private md5 functions to not clash with other libraries (ugh) --- Common/Crypto/md5.cpp | 58 +++++++++++++++++++++---------------------- Common/Crypto/md5.h | 20 +++++++-------- Core/HLE/sceMd5.cpp | 16 ++++++------ 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Common/Crypto/md5.cpp b/Common/Crypto/md5.cpp index 22a83956563f..cce49809dce7 100644 --- a/Common/Crypto/md5.cpp +++ b/Common/Crypto/md5.cpp @@ -62,7 +62,7 @@ /* * MD5 context setup */ -void md5_starts( md5_context *ctx ) +void ppsspp_md5_starts( md5_context *ctx ) { ctx->total[0] = 0; ctx->total[1] = 0; @@ -73,7 +73,7 @@ void md5_starts( md5_context *ctx ) ctx->state[3] = 0x10325476; } -static void md5_process( md5_context *ctx, unsigned char data[64] ) +static void ppsspp_md5_process( md5_context *ctx, unsigned char data[64] ) { unsigned long X[16], A, B, C, D; @@ -199,7 +199,7 @@ static void md5_process( md5_context *ctx, unsigned char data[64] ) /* * MD5 process buffer */ -void md5_update( md5_context *ctx, unsigned char *input, int ilen ) +void ppsspp_md5_update( md5_context *ctx, unsigned char *input, int ilen ) { int fill; unsigned long left; @@ -220,7 +220,7 @@ void md5_update( md5_context *ctx, unsigned char *input, int ilen ) { memcpy( (void *) (ctx->buffer + left), (void *) input, fill ); - md5_process( ctx, ctx->buffer ); + ppsspp_md5_process( ctx, ctx->buffer ); input += fill; ilen -= fill; left = 0; @@ -228,7 +228,7 @@ void md5_update( md5_context *ctx, unsigned char *input, int ilen ) while( ilen >= 64 ) { - md5_process( ctx, input ); + ppsspp_md5_process( ctx, input ); input += 64; ilen -= 64; } @@ -251,7 +251,7 @@ static const unsigned char md5_padding[64] = /* * MD5 final digest */ -void md5_finish( md5_context *ctx, unsigned char output[16] ) +void ppsspp_md5_finish( md5_context *ctx, unsigned char output[16] ) { unsigned long last, padn; unsigned long high, low; @@ -267,8 +267,8 @@ void md5_finish( md5_context *ctx, unsigned char output[16] ) last = ctx->total[0] & 0x3F; padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); - md5_update( ctx, (unsigned char *) md5_padding, padn ); - md5_update( ctx, msglen, 8 ); + ppsspp_md5_update( ctx, (unsigned char *) md5_padding, padn ); + ppsspp_md5_update( ctx, msglen, 8 ); PUT_ULONG_LE( ctx->state[0], output, 0 ); PUT_ULONG_LE( ctx->state[1], output, 4 ); @@ -279,13 +279,13 @@ void md5_finish( md5_context *ctx, unsigned char output[16] ) /* * output = MD5( input buffer ) */ -void md5( unsigned char *input, int ilen, unsigned char output[16] ) +void ppsspp_md5( unsigned char *input, int ilen, unsigned char output[16] ) { md5_context ctx; - md5_starts( &ctx ); - md5_update( &ctx, input, ilen ); - md5_finish( &ctx, output ); + ppsspp_md5_starts( &ctx ); + ppsspp_md5_update( &ctx, input, ilen ); + ppsspp_md5_finish( &ctx, output ); memset( &ctx, 0, sizeof( md5_context ) ); } @@ -293,14 +293,14 @@ void md5( unsigned char *input, int ilen, unsigned char output[16] ) /* * MD5 HMAC context setup */ -void md5_hmac_starts( md5_context *ctx, unsigned char *key, int keylen ) +void ppsspp_md5_hmac_starts( md5_context *ctx, unsigned char *key, int keylen ) { int i; unsigned char sum[16]; if( keylen > 64 ) { - md5( key, keylen, sum ); + ppsspp_md5( key, keylen, sum ); keylen = 16; key = sum; } @@ -314,8 +314,8 @@ void md5_hmac_starts( md5_context *ctx, unsigned char *key, int keylen ) ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] ); } - md5_starts( ctx ); - md5_update( ctx, ctx->ipad, 64 ); + ppsspp_md5_starts( ctx ); + ppsspp_md5_update( ctx, ctx->ipad, 64 ); memset( sum, 0, sizeof( sum ) ); } @@ -323,23 +323,23 @@ void md5_hmac_starts( md5_context *ctx, unsigned char *key, int keylen ) /* * MD5 HMAC process buffer */ -void md5_hmac_update( md5_context *ctx, unsigned char *input, int ilen ) +void ppsspp_md5_hmac_update( md5_context *ctx, unsigned char *input, int ilen ) { - md5_update( ctx, input, ilen ); + ppsspp_md5_update( ctx, input, ilen ); } /* * MD5 HMAC final digest */ -void md5_hmac_finish( md5_context *ctx, unsigned char output[16] ) +void ppsspp_md5_hmac_finish( md5_context *ctx, unsigned char output[16] ) { unsigned char tmpbuf[16]; - md5_finish( ctx, tmpbuf ); - md5_starts( ctx ); - md5_update( ctx, ctx->opad, 64 ); - md5_update( ctx, tmpbuf, 16 ); - md5_finish( ctx, output ); + ppsspp_md5_finish( ctx, tmpbuf ); + ppsspp_md5_starts( ctx ); + ppsspp_md5_update( ctx, ctx->opad, 64 ); + ppsspp_md5_update( ctx, tmpbuf, 16 ); + ppsspp_md5_finish( ctx, output ); memset( tmpbuf, 0, sizeof( tmpbuf ) ); } @@ -347,14 +347,14 @@ void md5_hmac_finish( md5_context *ctx, unsigned char output[16] ) /* * output = HMAC-MD5( hmac key, input buffer ) */ -void md5_hmac( unsigned char *key, int keylen, unsigned char *input, int ilen, +void ppsspp_md5_hmac( unsigned char *key, int keylen, unsigned char *input, int ilen, unsigned char output[16] ) { md5_context ctx; - md5_hmac_starts( &ctx, key, keylen ); - md5_hmac_update( &ctx, input, ilen ); - md5_hmac_finish( &ctx, output ); + ppsspp_md5_hmac_starts( &ctx, key, keylen ); + ppsspp_md5_hmac_update( &ctx, input, ilen ); + ppsspp_md5_hmac_finish( &ctx, output ); memset( &ctx, 0, sizeof( md5_context ) ); } @@ -464,7 +464,7 @@ static const unsigned char md5_hmac_test_sum[7][16] = /* * Checkup routine */ -int md5_self_test( int verbose ) +int ppsspp_md5_self_test( int verbose ) { int i, buflen; unsigned char buf[1024]; diff --git a/Common/Crypto/md5.h b/Common/Crypto/md5.h index a69024d1163a..da522c34d55f 100644 --- a/Common/Crypto/md5.h +++ b/Common/Crypto/md5.h @@ -46,7 +46,7 @@ extern "C" { * * \param ctx context to be initialized */ -void md5_starts( md5_context *ctx ); +void ppsspp_md5_starts( md5_context *ctx ); /** * \brief MD5 process buffer @@ -55,7 +55,7 @@ void md5_starts( md5_context *ctx ); * \param input buffer holding the data * \param ilen length of the input data */ -void md5_update( md5_context *ctx, unsigned char *input, int ilen ); +void ppsspp_md5_update( md5_context *ctx, unsigned char *input, int ilen ); /** * \brief MD5 final digest @@ -63,7 +63,7 @@ void md5_update( md5_context *ctx, unsigned char *input, int ilen ); * \param ctx MD5 context * \param output MD5 checksum result */ -void md5_finish( md5_context *ctx, unsigned char output[16] ); +void ppsspp_md5_finish( md5_context *ctx, unsigned char output[16] ); /** * \brief Output = MD5( input buffer ) @@ -72,7 +72,7 @@ void md5_finish( md5_context *ctx, unsigned char output[16] ); * \param ilen length of the input data * \param output MD5 checksum result */ -void md5( unsigned char *input, int ilen, unsigned char output[16] ); +void ppsspp_md5( unsigned char *input, int ilen, unsigned char output[16] ); /** * \brief Output = MD5( file contents ) @@ -83,7 +83,7 @@ void md5( unsigned char *input, int ilen, unsigned char output[16] ); * \return 0 if successful, 1 if fopen failed, * or 2 if fread failed */ -int md5_file( char *path, unsigned char output[16] ); +int ppsspp_md5_file( char *path, unsigned char output[16] ); /** * \brief MD5 HMAC context setup @@ -92,7 +92,7 @@ int md5_file( char *path, unsigned char output[16] ); * \param key HMAC secret key * \param keylen length of the HMAC key */ -void md5_hmac_starts( md5_context *ctx, unsigned char *key, int keylen ); +void ppsspp_md5_hmac_starts( md5_context *ctx, unsigned char *key, int keylen ); /** * \brief MD5 HMAC process buffer @@ -101,7 +101,7 @@ void md5_hmac_starts( md5_context *ctx, unsigned char *key, int keylen ); * \param input buffer holding the data * \param ilen length of the input data */ -void md5_hmac_update( md5_context *ctx, unsigned char *input, int ilen ); +void ppsspp_md5_hmac_update( md5_context *ctx, unsigned char *input, int ilen ); /** * \brief MD5 HMAC final digest @@ -109,7 +109,7 @@ void md5_hmac_update( md5_context *ctx, unsigned char *input, int ilen ); * \param ctx HMAC context * \param output MD5 HMAC checksum result */ -void md5_hmac_finish( md5_context *ctx, unsigned char output[16] ); +void ppsspp_md5_hmac_finish( md5_context *ctx, unsigned char output[16] ); /** * \brief Output = HMAC-MD5( hmac key, input buffer ) @@ -120,7 +120,7 @@ void md5_hmac_finish( md5_context *ctx, unsigned char output[16] ); * \param ilen length of the input data * \param output HMAC-MD5 result */ -void md5_hmac( unsigned char *key, int keylen, +void ppsspp_md5_hmac( unsigned char *key, int keylen, unsigned char *input, int ilen, unsigned char output[16] ); @@ -129,7 +129,7 @@ void md5_hmac( unsigned char *key, int keylen, * * \return 0 if successful, or 1 if the test failed */ -int md5_self_test( int verbose ); +int ppsspp_md5_self_test( int verbose ); #ifdef __cplusplus } diff --git a/Core/HLE/sceMd5.cpp b/Core/HLE/sceMd5.cpp index cd71adcd8499..286294d2f004 100644 --- a/Core/HLE/sceMd5.cpp +++ b/Core/HLE/sceMd5.cpp @@ -57,7 +57,7 @@ static int sceMd5Digest(u32 dataAddr, u32 len, u32 digestAddr) { if (!Memory::IsValidAddress(dataAddr) || !Memory::IsValidAddress(digestAddr)) return -1; - md5(Memory::GetPointerWriteUnchecked(dataAddr), (int)len, Memory::GetPointerWriteUnchecked(digestAddr)); + ppsspp_md5(Memory::GetPointerWriteUnchecked(dataAddr), (int)len, Memory::GetPointerWriteUnchecked(digestAddr)); return 0; } @@ -69,7 +69,7 @@ static int sceMd5BlockInit(u32 ctxAddr) { // TODO: Until I know how large a context is, we just go all lazy and use a global context, // which will work just fine unless games do several MD5 concurrently. - md5_starts(&md5_ctx); + ppsspp_md5_starts(&md5_ctx); return 0; } @@ -78,7 +78,7 @@ static int sceMd5BlockUpdate(u32 ctxAddr, u32 dataPtr, u32 len) { if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(dataPtr)) return -1; - md5_update(&md5_ctx, Memory::GetPointerWriteUnchecked(dataPtr), (int)len); + ppsspp_md5_update(&md5_ctx, Memory::GetPointerWriteUnchecked(dataPtr), (int)len); return 0; } @@ -87,7 +87,7 @@ static int sceMd5BlockResult(u32 ctxAddr, u32 digestAddr) { if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(digestAddr)) return -1; - md5_finish(&md5_ctx, Memory::GetPointerWriteUnchecked(digestAddr)); + ppsspp_md5_finish(&md5_ctx, Memory::GetPointerWriteUnchecked(digestAddr)); return 0; } @@ -97,7 +97,7 @@ int sceKernelUtilsMd5Digest(u32 dataAddr, int len, u32 digestAddr) { if (!Memory::IsValidAddress(dataAddr) || !Memory::IsValidAddress(digestAddr)) return -1; - md5(Memory::GetPointerWriteUnchecked(dataAddr), (int)len, Memory::GetPointerWriteUnchecked(digestAddr)); + ppsspp_md5(Memory::GetPointerWriteUnchecked(dataAddr), (int)len, Memory::GetPointerWriteUnchecked(digestAddr)); return 0; } @@ -109,7 +109,7 @@ int sceKernelUtilsMd5BlockInit(u32 ctxAddr) { // TODO: Until I know how large a context is, we just go all lazy and use a global context, // which will work just fine unless games do several MD5 concurrently. - md5_starts(&md5_ctx); + ppsspp_md5_starts(&md5_ctx); return 0; } @@ -118,7 +118,7 @@ int sceKernelUtilsMd5BlockUpdate(u32 ctxAddr, u32 dataPtr, int len) { if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(dataPtr)) return -1; - md5_update(&md5_ctx, Memory::GetPointerWriteUnchecked(dataPtr), (int)len); + ppsspp_md5_update(&md5_ctx, Memory::GetPointerWriteUnchecked(dataPtr), (int)len); return 0; } @@ -127,7 +127,7 @@ int sceKernelUtilsMd5BlockResult(u32 ctxAddr, u32 digestAddr) { if (!Memory::IsValidAddress(ctxAddr) || !Memory::IsValidAddress(digestAddr)) return -1; - md5_finish(&md5_ctx, Memory::GetPointerWriteUnchecked(digestAddr)); + ppsspp_md5_finish(&md5_ctx, Memory::GetPointerWriteUnchecked(digestAddr)); return 0; } From 31a6cecef92233d1714063f52a89c8efc3bbb98e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 17 Jun 2023 22:43:58 +0200 Subject: [PATCH 5/6] Allow specifying content-type for posts instead of hardcoding. --- Common/Net/HTTPClient.cpp | 2 +- Common/Net/HTTPClient.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Common/Net/HTTPClient.cpp b/Common/Net/HTTPClient.cpp index 43b30f760264..e8d3b6c7f54e 100644 --- a/Common/Net/HTTPClient.cpp +++ b/Common/Net/HTTPClient.cpp @@ -604,8 +604,8 @@ std::shared_ptr Downloader::StartDownloadWithCallback( std::shared_ptr Downloader::AsyncPostWithCallback( const std::string &url, const std::string &postData, + const std::string &postMime, std::function callback) { - std::string postMime = "application/x-www-form-urlencoded"; std::shared_ptr dl(new Download(RequestMethod::POST, url, postData, postMime, Path())); dl->SetCallback(callback); newDownloads_.push_back(dl); diff --git a/Common/Net/HTTPClient.h b/Common/Net/HTTPClient.h index f6b832b834b9..7a0a87f3c05e 100644 --- a/Common/Net/HTTPClient.h +++ b/Common/Net/HTTPClient.h @@ -202,6 +202,7 @@ class Downloader { std::shared_ptr AsyncPostWithCallback( const std::string &url, const std::string &postData, + const std::string &postMime, // Use postMime = "application/x-www-form-urlencoded" for standard form-style posts, such as used by retroachievements. std::function callback); // Drops finished downloads from the list. From 0983927319c3430754fc042309bd23839fb8ac26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 17 Jun 2023 23:19:23 +0200 Subject: [PATCH 6/6] Comment cleanup --- Common/Net/HTTPClient.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Common/Net/HTTPClient.h b/Common/Net/HTTPClient.h index 7a0a87f3c05e..eb1338cabc83 100644 --- a/Common/Net/HTTPClient.h +++ b/Common/Net/HTTPClient.h @@ -105,7 +105,6 @@ enum class RequestMethod { // Really an asynchronous request. class Download { public: - // 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(); @@ -202,7 +201,7 @@ class Downloader { std::shared_ptr AsyncPostWithCallback( const std::string &url, const std::string &postData, - const std::string &postMime, // Use postMime = "application/x-www-form-urlencoded" for standard form-style posts, such as used by retroachievements. + const std::string &postMime, // Use postMime = "application/x-www-form-urlencoded" for standard form-style posts, such as used by retroachievements. For encoding form data manually we have MultipartFormDataEncoder. std::function callback); // Drops finished downloads from the list.