#include <HttpClient.h>

Inheritance diagram for HttpClient:
Collaboration diagram for HttpClient:

Public Member Functions

virtual ~HttpClient ()
 HttpClient destructor. More...
 
bool sendRequest (const Url &url, RequestCompletedDelegate requestComplete)
 
bool sendRequest (const HttpMethod method, const Url &url, const HttpHeaders &headers, RequestCompletedDelegate requestComplete)
 
bool sendRequest (const HttpMethod method, const Url &url, const HttpHeaders &headers, const String &body, RequestCompletedDelegate requestComplete)
 
bool sendRequest (const HttpMethod method, const Url &url, const HttpHeaders &headers, String &&body, RequestCompletedDelegate requestComplete) noexcept
 
bool downloadString (const Url &url, RequestCompletedDelegate requestComplete, size_t maxLength=NETWORK_SEND_BUFFER_SIZE)
 Queue request to download content as string (in memory) More...
 
bool downloadFile (const Url &url, RequestCompletedDelegate requestComplete=nullptr)
 
bool downloadFile (const Url &url, const String &saveFileName, RequestCompletedDelegate requestComplete=nullptr)
 Queue request to download a file. More...
 
bool send (HttpRequest *request)
 
HttpRequestcreateRequest (const Url &url)
 Helper function to create a new request on a URL. More...
 

Static Public Member Functions

static void cleanup ()
 Use this method to clean all object pools. More...
 

Protected Types

using HttpConnectionPool = ObjectMap< String, HttpClientConnection >
 

Protected Member Functions

String getCacheKey (const Url &url)
 

Static Protected Attributes

static HttpConnectionPool httpConnectionPool
 

Member Typedef Documentation

◆ HttpConnectionPool

Constructor & Destructor Documentation

◆ ~HttpClient()

virtual HttpClient::~HttpClient ( )
inlinevirtual

HttpClient destructor.

Note
DON'T call cleanup. If you want to free all resources from HttpClients the correct sequence will be to
  1. Delete all instances of HttpClient
  2. Call the static method HttpClient::cleanup();

Member Function Documentation

◆ cleanup()

static void HttpClient::cleanup ( )
inlinestatic

Use this method to clean all object pools.

◆ createRequest()

HttpRequest* HttpClient::createRequest ( const Url url)
inline

Helper function to create a new request on a URL.

Parameters
url
Return values
HttpRequest*

◆ downloadFile() [1/2]

bool HttpClient::downloadFile ( const Url url,
const String saveFileName,
RequestCompletedDelegate  requestComplete = nullptr 
)

Queue request to download a file.

Parameters
urlSource of file data
saveFileNamePath to save file to. Optional: specify nullptr to use name from url
requestCompleteCompletion callback

◆ downloadFile() [2/2]

bool HttpClient::downloadFile ( const Url url,
RequestCompletedDelegate  requestComplete = nullptr 
)
inline

◆ downloadString()

bool HttpClient::downloadString ( const Url url,
RequestCompletedDelegate  requestComplete,
size_t  maxLength = NETWORK_SEND_BUFFER_SIZE 
)
inline

Queue request to download content as string (in memory)

Parameters
urlURL from which the content will be fetched
requestCompleteCompletion callback
maxLengthmaximum bytes to store in memory. If the response is bigger than maxLength then the rest bytes will be discarded. Use this parameter wisely as setting the value too high may consume all available RAM resulting in device restart and Denial-Of-Service

◆ getCacheKey()

String HttpClient::getCacheKey ( const Url url)
inlineprotected

◆ send()

bool HttpClient::send ( HttpRequest request)

◆ sendRequest() [1/4]

bool HttpClient::sendRequest ( const HttpMethod  method,
const Url url,
const HttpHeaders headers,
const String body,
RequestCompletedDelegate  requestComplete 
)
inline

◆ sendRequest() [2/4]

bool HttpClient::sendRequest ( const HttpMethod  method,
const Url url,
const HttpHeaders headers,
RequestCompletedDelegate  requestComplete 
)
inline

◆ sendRequest() [3/4]

bool HttpClient::sendRequest ( const HttpMethod  method,
const Url url,
const HttpHeaders headers,
String &&  body,
RequestCompletedDelegate  requestComplete 
)
inlinenoexcept

◆ sendRequest() [4/4]

bool HttpClient::sendRequest ( const Url url,
RequestCompletedDelegate  requestComplete 
)
inline

Member Data Documentation

◆ httpConnectionPool

HttpConnectionPool HttpClient::httpConnectionPool
staticprotected

The documentation for this class was generated from the following file: