diff options
Diffstat (limited to '')
-rw-r--r-- | src/HTTP/UrlClient.h | 48 |
1 files changed, 42 insertions, 6 deletions
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<cCallbacks> cCallbacksPtr; + using cCallbacksPtr = std::unique_ptr<cCallbacks>; /** 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<bool, AString> 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<bool, AString> 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<bool, AString> 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<bool, AString> BlockingPost( + const AString & a_URL, + AStringMap && a_Headers, + const AString & a_Body, + AStringMap && a_Options + ); + + /** Alias for BlockingRequest("PUT", ...) */ + static std::pair<bool, AString> BlockingPut( + const AString & a_URL, + AStringMap && a_Headers, + const AString & a_Body, AStringMap && a_Options ); }; |