28 #include "../OSSupport/Network.h"
73 virtual void OnBodyData(
const void * a_Data,
size_t a_Size) {}
114 static std::pair<bool, AString>
Request(
124 static std::pair<bool, AString>
Get(
133 static std::pair<bool, AString>
Post(
142 static std::pair<bool, AString>
Put(
std::map< AString, AString > AStringMap
A string dictionary, used for key-value pairs.
static std::pair< bool, AString > BlockingPut(const AString &a_URL, AStringMap &&a_Headers, const AString &a_Body, const AStringMap &a_Options={})
Alias for BlockingRequest("PUT", ...)
static std::pair< bool, AString > BlockingRequest(const AString &a_Method, const AString &a_URL, AStringMap &&a_Headers={}, const AString &a_Body={}, const AStringMap &a_Options={})
Sends a generic request and block until a response is received or an error occurs.
std::shared_ptr< cCallbacks > cCallbacksPtr
static std::pair< bool, AString > Put(const AString &a_URL, cCallbacksPtr &&a_Callbacks, AStringMap &&a_Headers, const AString &a_Body, const AStringMap &a_Options={})
Alias for Request("PUT", ...)
static std::pair< bool, AString > Request(const AString &a_Method, const AString &a_URL, cCallbacksPtr &&a_Callbacks, AStringMap &&a_Headers, const AString &a_Body, const AStringMap &a_Options)
Makes a network request to the specified URL, using the specified method (if applicable).
eHTTPStatus
Used for HTTP status codes.
@ HTTP_STATUS_MULTIPLE_CHOICES
@ HTTP_STATUS_MOVED_PERMANENTLY
@ HTTP_STATUS_TEMPORARY_REDIRECT
static std::pair< bool, AString > BlockingPost(const AString &a_URL, AStringMap &&a_Headers, const AString &a_Body, const AStringMap &a_Options={})
Alias for BlockingRequest("POST", ...)
static std::pair< bool, AString > BlockingGet(const AString &a_URL, AStringMap a_Headers={}, const AString &a_Body={}, const AStringMap &a_Options={})
Alias for BlockingRequest("GET", ...)
static std::pair< bool, AString > Post(const AString &a_URL, cCallbacksPtr &&a_Callbacks, AStringMap &&a_Headers, const AString &a_Body, const AStringMap &a_Options={})
Alias for Request("POST", ...)
static std::pair< bool, AString > Get(const AString &a_URL, cCallbacksPtr &&a_Callbacks, AStringMap &&a_Headers={}, const AString &a_Body={}, const AStringMap &a_Options={})
Alias for Request("GET", ...)
Callbacks that are used for progress and result reporting.
virtual void OnTlsHandshakeCompleted()
Called for TLS connections, when the TLS handshake has been completed.
virtual void OnHeadersFinished()
Called when the HTTP headers have been fully parsed, unless the response is an allowed redirect.
virtual void OnConnected(cTCPLink &a_Link)
Called when the TCP connection is established.
virtual void OnStatusLine(const AString &a_HttpVersion, int a_StatusCode, const AString &a_Rest)
Called after the first line of the response is parsed, unless the response is an allowed redirect.
virtual void OnRedirecting(const AString &a_NewLocation)
Called when a redirect is to be followed.
virtual bool OnCertificateReceived()
Called for TLS connections, when the server certificate is received.
virtual void OnRequestSent()
Called after the entire request has been sent to the remote peer.
virtual void OnHeader(const AString &a_Key, const AString &a_Value)
Called when a single HTTP header is received and parsed, unless the response is an allowed redirect C...
virtual void OnBodyData(const void *a_Data, size_t a_Size)
Called when the next fragment of the response body is received, unless the response is an allowed red...
virtual void OnError(const AString &a_ErrorMsg)
Called when an asynchronous error is encountered.
virtual void OnBodyFinished()
Called after the response body has been fully reported by OnBody() calls, unless the response is an a...
Interface that provides the methods available on a single TCP connection.