summaryrefslogtreecommitdiffstats
path: root/src/HTTP/UrlClient.h
diff options
context:
space:
mode:
authorx12xx12x <44411062+12xx12@users.noreply.github.com>2023-03-26 14:48:06 +0200
committerMattes D <github@xoft.cz>2023-05-19 16:25:12 +0200
commit800f1c0bc5bd4632bd0f246c756283cc47d31a34 (patch)
tree9200f7d4bb2a4e3d91161468859c403f9933eae1 /src/HTTP/UrlClient.h
parentRemoved all Printf-family functions from StringUtils. (diff)
downloadcuberite-800f1c0bc5bd4632bd0f246c756283cc47d31a34.tar
cuberite-800f1c0bc5bd4632bd0f246c756283cc47d31a34.tar.gz
cuberite-800f1c0bc5bd4632bd0f246c756283cc47d31a34.tar.bz2
cuberite-800f1c0bc5bd4632bd0f246c756283cc47d31a34.tar.lz
cuberite-800f1c0bc5bd4632bd0f246c756283cc47d31a34.tar.xz
cuberite-800f1c0bc5bd4632bd0f246c756283cc47d31a34.tar.zst
cuberite-800f1c0bc5bd4632bd0f246c756283cc47d31a34.zip
Diffstat (limited to '')
-rw-r--r--src/HTTP/UrlClient.h48
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
);
};