Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetNetIf NTPClient_NetServices mbed ConfigFile
HTTPClient Class Reference
A simple HTTP Client. More...
#include <HTTPClient.h>
Public Member Functions | |
| HTTPClient () | |
| Instantiates the HTTP client. | |
| void | basicAuth (const char *user, const char *password) |
| Provides a basic authentification feature (Base64 encoded username and password) | |
| HTTPResult | get (const char *uri, HTTPData *pDataIn) |
| Executes a GET Request (blocking) | |
| HTTPResult | get (const char *uri, HTTPData *pDataIn, void(*pMethod)(HTTPResult)) |
| Executes a GET Request (non blocking) | |
| template<class T > | |
| HTTPResult | get (const char *uri, HTTPData *pDataIn, T *pItem, void(T::*pMethod)(HTTPResult)) |
| Executes a GET Request (non blocking) | |
| HTTPResult | post (const char *uri, const HTTPData &dataOut, HTTPData *pDataIn) |
| Executes a POST Request (blocking) | |
| HTTPResult | post (const char *uri, const HTTPData &dataOut, HTTPData *pDataIn, void(*pMethod)(HTTPResult)) |
| Executes a POST Request (non blocking) | |
| template<class T > | |
| HTTPResult | post (const char *uri, const HTTPData &dataOut, HTTPData *pDataIn, T *pItem, void(T::*pMethod)(HTTPResult)) |
| Executes a POST Request (non blocking) | |
| void | doGet (const char *uri, HTTPData *pDataIn) |
| Executes a GET Request (non blocking) | |
| void | doPost (const char *uri, const HTTPData &dataOut, HTTPData *pDataIn) |
| Executes a POST Request (non blocking) | |
| void | setOnResult (void(*pMethod)(HTTPResult)) |
| Setups the result callback. | |
| void | setTimeout (int ms) |
| Setups timeout. | |
| int | getHTTPResponseCode () |
| Gets last request's HTTP response code. | |
| void | setRequestHeader (const string &header, const string &value) |
| Sets a specific request header. | |
| string & | getResponseHeader (const string &header) |
| Gets a response header. | |
| void | resetRequestHeaders () |
| Clears request headers. | |
| HTTPClient () | |
| Instantiates the HTTP client. | |
| void | basicAuth (const char *user, const char *password) |
| Provides a basic authentification feature (Base64 encoded username and password) | |
| HTTPResult | get (const char *uri, HTTPData *pDataIn) |
| Executes a GET Request (blocking) | |
| HTTPResult | get (const char *uri, HTTPData *pDataIn, void(*pMethod)(HTTPResult)) |
| Executes a GET Request (non blocking) | |
| template<class T > | |
| HTTPResult | get (const char *uri, HTTPData *pDataIn, T *pItem, void(T::*pMethod)(HTTPResult)) |
| Executes a GET Request (non blocking) | |
| HTTPResult | post (const char *uri, const HTTPData &dataOut, HTTPData *pDataIn) |
| Executes a POST Request (blocking) | |
| HTTPResult | post (const char *uri, const HTTPData &dataOut, HTTPData *pDataIn, void(*pMethod)(HTTPResult)) |
| Executes a POST Request (non blocking) | |
| template<class T > | |
| HTTPResult | post (const char *uri, const HTTPData &dataOut, HTTPData *pDataIn, T *pItem, void(T::*pMethod)(HTTPResult)) |
| Executes a POST Request (non blocking) | |
| void | doGet (const char *uri, HTTPData *pDataIn) |
| Executes a GET Request (non blocking) | |
| void | doPost (const char *uri, const HTTPData &dataOut, HTTPData *pDataIn) |
| Executes a POST Request (non blocking) | |
| void | setOnResult (void(*pMethod)(HTTPResult)) |
| Setups the result callback. | |
| void | setTimeout (int ms) |
| Setups timeout. | |
| int | getHTTPResponseCode () |
| Gets last request's HTTP response code. | |
| void | setRequestHeader (const string &header, const string &value) |
| Sets a specific request header. | |
| string & | getResponseHeader (const string &header) |
| Gets a response header. | |
| void | resetRequestHeaders () |
| Clears request headers. | |
Detailed Description
A simple HTTP Client.
The HTTPClient is composed of:
- The actual client (HTTPClient)
- Classes that act as a data repository, each of which deriving from the HTTPData class (HTTPText for short text content, HTTPFile for file I/O, HTTPMap for key/value pairs, and HTTPStream for streaming purposes)
Definition at line 68 of file LPC1768/services/http/client/HTTPClient.h.
Constructor & Destructor Documentation
| HTTPClient | ( | ) |
Instantiates the HTTP client.
| HTTPClient | ( | ) |
Instantiates the HTTP client.
Member Function Documentation
| void basicAuth | ( | const char * | user, |
| const char * | password | ||
| ) |
Provides a basic authentification feature (Base64 encoded username and password)
| void basicAuth | ( | const char * | user, |
| const char * | password | ||
| ) |
Provides a basic authentification feature (Base64 encoded username and password)
| void doGet | ( | const char * | uri, |
| HTTPData * | pDataIn | ||
| ) |
Executes a GET Request (non blocking)
Executes a GET request on the URI uri
- Parameters:
-
uri : URI on which to execute the request pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL The function returns immediately and calls the previously set callback on completion or error
| void doGet | ( | const char * | uri, |
| HTTPData * | pDataIn | ||
| ) |
Executes a GET Request (non blocking)
Executes a GET request on the URI uri
- Parameters:
-
uri : URI on which to execute the request pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL The function returns immediately and calls the previously set callback on completion or error
| void doPost | ( | const char * | uri, |
| const HTTPData & | dataOut, | ||
| HTTPData * | pDataIn | ||
| ) |
Executes a POST Request (non blocking)
Executes a POST request on the URI uri
- Parameters:
-
uri : URI on which to execute the request dataOut : a HTTPData instance that contains the data that will be posted pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL pMethod : callback function The function returns immediately and calls the previously set callback on completion or error
| void doPost | ( | const char * | uri, |
| const HTTPData & | dataOut, | ||
| HTTPData * | pDataIn | ||
| ) |
Executes a POST Request (non blocking)
Executes a POST request on the URI uri
- Parameters:
-
uri : URI on which to execute the request dataOut : a HTTPData instance that contains the data that will be posted pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL pMethod : callback function The function returns immediately and calls the previously set callback on completion or error
| HTTPResult get | ( | const char * | uri, |
| HTTPData * | pDataIn, | ||
| T * | pItem, | ||
| void(T::*)(HTTPResult) | pMethod | ||
| ) |
Executes a GET Request (non blocking)
Executes a GET request on the URI uri
- Parameters:
-
uri : URI on which to execute the request pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL pItem : instance of class on which to execute the callback method pMethod : callback method The function returns immediately and calls the callback on completion or error
Definition at line 108 of file LPC1768/services/http/client/HTTPClient.h.
| HTTPResult get | ( | const char * | uri, |
| HTTPData * | pDataIn, | ||
| void(*)(HTTPResult) | pMethod | ||
| ) |
Executes a GET Request (non blocking)
Executes a GET request on the URI uri
- Parameters:
-
uri : URI on which to execute the request pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL pMethod : callback function The function returns immediately and calls the callback on completion or error
| HTTPResult get | ( | const char * | uri, |
| HTTPData * | pDataIn, | ||
| T * | pItem, | ||
| void(T::*)(HTTPResult) | pMethod | ||
| ) |
Executes a GET Request (non blocking)
Executes a GET request on the URI uri
- Parameters:
-
uri : URI on which to execute the request pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL pItem : instance of class on which to execute the callback method pMethod : callback method The function returns immediately and calls the callback on completion or error
Definition at line 108 of file LPC2368/services/http/client/HTTPClient.h.
| HTTPResult get | ( | const char * | uri, |
| HTTPData * | pDataIn | ||
| ) |
Executes a GET Request (blocking)
Executes a GET request on the URI uri
- Parameters:
-
uri : URI on which to execute the request pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL Blocks until completion
| HTTPResult get | ( | const char * | uri, |
| HTTPData * | pDataIn, | ||
| void(*)(HTTPResult) | pMethod | ||
| ) |
Executes a GET Request (non blocking)
Executes a GET request on the URI uri
- Parameters:
-
uri : URI on which to execute the request pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL pMethod : callback function The function returns immediately and calls the callback on completion or error
| HTTPResult get | ( | const char * | uri, |
| HTTPData * | pDataIn | ||
| ) |
Executes a GET Request (blocking)
Executes a GET request on the URI uri
- Parameters:
-
uri : URI on which to execute the request pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL Blocks until completion
| int getHTTPResponseCode | ( | ) |
Gets last request's HTTP response code.
- Returns:
- The HTTP response code of the last request
| int getHTTPResponseCode | ( | ) |
Gets last request's HTTP response code.
- Returns:
- The HTTP response code of the last request
| string& getResponseHeader | ( | const string & | header ) |
Gets a response header.
| string& getResponseHeader | ( | const string & | header ) |
Gets a response header.
| HTTPResult post | ( | const char * | uri, |
| const HTTPData & | dataOut, | ||
| HTTPData * | pDataIn | ||
| ) |
Executes a POST Request (blocking)
Executes a POST request on the URI uri
- Parameters:
-
uri : URI on which to execute the request dataOut : a HTTPData instance that contains the data that will be posted pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL Blocks until completion
| HTTPResult post | ( | const char * | uri, |
| const HTTPData & | dataOut, | ||
| HTTPData * | pDataIn, | ||
| void(*)(HTTPResult) | pMethod | ||
| ) |
Executes a POST Request (non blocking)
Executes a POST request on the URI uri
- Parameters:
-
uri : URI on which to execute the request dataOut : a HTTPData instance that contains the data that will be posted pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL pMethod : callback function The function returns immediately and calls the callback on completion or error
| HTTPResult post | ( | const char * | uri, |
| const HTTPData & | dataOut, | ||
| HTTPData * | pDataIn, | ||
| T * | pItem, | ||
| void(T::*)(HTTPResult) | pMethod | ||
| ) |
Executes a POST Request (non blocking)
Executes a POST request on the URI uri
- Parameters:
-
uri : URI on which to execute the request dataOut : a HTTPData instance that contains the data that will be posted pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL pItem : instance of class on which to execute the callback method pMethod : callback method The function returns immediately and calls the callback on completion or error
Definition at line 147 of file LPC2368/services/http/client/HTTPClient.h.
| HTTPResult post | ( | const char * | uri, |
| const HTTPData & | dataOut, | ||
| HTTPData * | pDataIn | ||
| ) |
Executes a POST Request (blocking)
Executes a POST request on the URI uri
- Parameters:
-
uri : URI on which to execute the request dataOut : a HTTPData instance that contains the data that will be posted pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL Blocks until completion
| HTTPResult post | ( | const char * | uri, |
| const HTTPData & | dataOut, | ||
| HTTPData * | pDataIn, | ||
| T * | pItem, | ||
| void(T::*)(HTTPResult) | pMethod | ||
| ) |
Executes a POST Request (non blocking)
Executes a POST request on the URI uri
- Parameters:
-
uri : URI on which to execute the request dataOut : a HTTPData instance that contains the data that will be posted pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL pItem : instance of class on which to execute the callback method pMethod : callback method The function returns immediately and calls the callback on completion or error
Definition at line 147 of file LPC1768/services/http/client/HTTPClient.h.
| HTTPResult post | ( | const char * | uri, |
| const HTTPData & | dataOut, | ||
| HTTPData * | pDataIn, | ||
| void(*)(HTTPResult) | pMethod | ||
| ) |
Executes a POST Request (non blocking)
Executes a POST request on the URI uri
- Parameters:
-
uri : URI on which to execute the request dataOut : a HTTPData instance that contains the data that will be posted pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL pMethod : callback function The function returns immediately and calls the callback on completion or error
| void resetRequestHeaders | ( | ) |
Clears request headers.
| void resetRequestHeaders | ( | ) |
Clears request headers.
| void setOnResult | ( | void(*)(HTTPResult) | pMethod ) |
Setups the result callback.
- Parameters:
-
pMethod : callback function
| void setOnResult | ( | void(*)(HTTPResult) | pMethod ) |
Setups the result callback.
- Parameters:
-
pMethod : callback function
| void setRequestHeader | ( | const string & | header, |
| const string & | value | ||
| ) |
Sets a specific request header.
| void setRequestHeader | ( | const string & | header, |
| const string & | value | ||
| ) |
Sets a specific request header.
| void setTimeout | ( | int | ms ) |
Setups timeout.
- Parameters:
-
ms : time of connection inactivity in ms after which the request should timeout
| void setTimeout | ( | int | ms ) |
Setups timeout.
- Parameters:
-
ms : time of connection inactivity in ms after which the request should timeout
Generated on Tue Jul 12 2022 10:57:43 by
1.7.2