From 800f1c0bc5bd4632bd0f246c756283cc47d31a34 Mon Sep 17 00:00:00 2001 From: x12xx12x <44411062+12xx12@users.noreply.github.com> Date: Sun, 26 Mar 2023 14:48:06 +0200 Subject: Auth SSL Fixes - Fixed Login Breaking bug - Auth and MojangAPI now use UrlClient - fixed bug in UrlClient where one letter was missing in the HTTP Header - added function to verify Urls from config files and error handling on bad Urls in config for Auth --- src/HTTP/UrlClient.h | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'src/HTTP/UrlClient.h') diff --git a/src/HTTP/UrlClient.h b/src/HTTP/UrlClient.h index 5f737b057..aaff60a87 100644 --- a/src/HTTP/UrlClient.h +++ b/src/HTTP/UrlClient.h @@ -86,7 +86,7 @@ public: for such a response; instead, the redirect is silently attempted. */ virtual void OnRedirecting(const AString & a_NewLocation) {} }; - typedef std::unique_ptr cCallbacksPtr; + using cCallbacksPtr = std::unique_ptr; /** Used for HTTP status codes. */ @@ -115,7 +115,7 @@ public: const AString & a_URL, cCallbacksPtr && a_Callbacks, AStringMap && a_Headers, - AString && a_Body, + const AString & a_Body, AStringMap && a_Options ); @@ -123,9 +123,9 @@ public: static std::pair Get( const AString & a_URL, cCallbacksPtr && a_Callbacks, - AStringMap a_Headers = AStringMap(), + AStringMap && a_Headers = AStringMap(), const AString & a_Body = AString(), - AStringMap a_Options = AStringMap() + AStringMap && a_Options = AStringMap() ); /** Alias for Request("POST", ...) */ @@ -133,7 +133,7 @@ public: const AString & a_URL, cCallbacksPtr && a_Callbacks, AStringMap && a_Headers, - AString && a_Body, + const AString & a_Body, AStringMap && a_Options ); @@ -142,7 +142,43 @@ public: const AString & a_URL, cCallbacksPtr && a_Callbacks, AStringMap && a_Headers, - AString && a_Body, + const AString & a_Body, + AStringMap && a_Options + ); + + /** The method will run a thread blocking HTTP request. Any error handling + is done inside the functions. Check the LOG or stdout for any occurring + errors. Other parameters are the same as for the regular request method. + The return value is if the request was successful and the response. */ + static std::pair BlockingRequest( + const AString & a_Method, + const AString & a_URL, + AStringMap && a_Headers = AStringMap(), + const AString & a_Body = AString(), + AStringMap && a_Options = AStringMap() + ); + + /** Alias for BlockingRequest("GET", ...) */ + static std::pair BlockingGet( + const AString & a_URL, + AStringMap a_Headers = AStringMap(), + const AString & a_Body = AString(), + AStringMap a_Options = AStringMap() + ); + + /** Alias for BlockingRequest("POST", ...) */ + static std::pair BlockingPost( + const AString & a_URL, + AStringMap && a_Headers, + const AString & a_Body, + AStringMap && a_Options + ); + + /** Alias for BlockingRequest("PUT", ...) */ + static std::pair BlockingPut( + const AString & a_URL, + AStringMap && a_Headers, + const AString & a_Body, AStringMap && a_Options ); }; -- cgit v1.2.3