Sarah Marsh / HTTPClient-SSL

Dependencies:   CyaSSL

Dependents:   ECE_4180_Lab_4 IoT_Security_WIFI ESP8266_HTTP_HelloWorld ESP8266_ws_hw ... more

Fork of HTTPClient-SSL by Doug Anson

Embed: (wiki syntax)

« Back to documentation index

HTTPClient Class Reference

HTTPClient Class Reference

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)
More...

#include <HTTPClient.h>

Public Member Functions

 HTTPClient ()
 Instantiate the HTTP client.
HTTPResult oauthToken (const char *token)
 Provides a OAUTH2 authentification feature Pass NULL pointer to switch back to no authentication.
HTTPResult basicAuth (const char *user, const char *password)
 Provides a basic authentification feature (Base64 encoded username and password) Pass two NULL pointers to switch back to no authentication.
HTTPResult get (const char *url, IHTTPDataIn *pDataIn, int timeout=HTTP_CLIENT_DEFAULT_TIMEOUT)
 Execute a GET request on the URL Blocks until completion.
HTTPResult get (const char *url, char *result, size_t maxResultLen, int timeout=HTTP_CLIENT_DEFAULT_TIMEOUT)
 Execute a GET request on the URL Blocks until completion This is a helper to directly get a piece of text from a HTTP result.
HTTPResult post (const char *url, const IHTTPDataOut &dataOut, IHTTPDataIn *pDataIn, int timeout=HTTP_CLIENT_DEFAULT_TIMEOUT)
 Execute a POST request on the URL Blocks until completion.
HTTPResult put (const char *url, const IHTTPDataOut &dataOut, IHTTPDataIn *pDataIn, int timeout=HTTP_CLIENT_DEFAULT_TIMEOUT)
 Execute a PUT request on the URL Blocks until completion.
HTTPResult del (const char *url, IHTTPDataIn *pDataIn, int timeout=HTTP_CLIENT_DEFAULT_TIMEOUT)
 Execute a DELETE request on the URL Blocks until completion.
int getHTTPResponseCode ()
 Get last request's HTTP response code.

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 56 of file HTTPClient.h.


Constructor & Destructor Documentation

HTTPClient (  )

Instantiate the HTTP client.

Definition at line 135 of file HTTPClient.cpp.


Member Function Documentation

HTTPResult basicAuth ( const char *  user,
const char *  password 
)

Provides a basic authentification feature (Base64 encoded username and password) Pass two NULL pointers to switch back to no authentication.

Parameters:
userusername to use for authentication, must remain valid durlng the whole HTTP session
userpassword to use for authentication, must remain valid durlng the whole HTTP session

Definition at line 175 of file HTTPClient.cpp.

HTTPResult del ( const char *  url,
IHTTPDataIn pDataIn,
int  timeout = HTTP_CLIENT_DEFAULT_TIMEOUT 
)

Execute a DELETE request on the URL Blocks until completion.

Parameters:
url: url on which to execute the request
pDataIn: pointer to an IHTTPDataIn instance that will collect the data returned by the request, can be NULL
timeoutwaiting timeout in ms (osWaitForever for blocking function, not recommended)
Returns:
0 on success, HTTP error (<0) on failure

Definition at line 219 of file HTTPClient.cpp.

HTTPResult get ( const char *  url,
char *  result,
size_t  maxResultLen,
int  timeout = HTTP_CLIENT_DEFAULT_TIMEOUT 
)

Execute a GET request on the URL Blocks until completion This is a helper to directly get a piece of text from a HTTP result.

Parameters:
url: url on which to execute the request
result: pointer to a char array in which the result will be stored
maxResultLen: length of the char array (including space for the NULL-terminating char)
timeoutwaiting timeout in ms (osWaitForever for blocking function, not recommended)
Returns:
0 on success, HTTP error (<0) on failure

Definition at line 203 of file HTTPClient.cpp.

HTTPResult get ( const char *  url,
IHTTPDataIn pDataIn,
int  timeout = HTTP_CLIENT_DEFAULT_TIMEOUT 
)

Execute a GET request on the URL Blocks until completion.

Parameters:
url: url on which to execute the request
pDataIn: pointer to an IHTTPDataIn instance that will collect the data returned by the request, can be NULL
timeoutwaiting timeout in ms (osWaitForever for blocking function, not recommended)
Returns:
0 on success, HTTP error (<0) on failure

Definition at line 198 of file HTTPClient.cpp.

int getHTTPResponseCode (  )

Get last request's HTTP response code.

Returns:
The HTTP response code of the last request

Definition at line 225 of file HTTPClient.cpp.

HTTPResult oauthToken ( const char *  token )

Provides a OAUTH2 authentification feature Pass NULL pointer to switch back to no authentication.

Parameters:
tokenOAUTH2 token

Definition at line 159 of file HTTPClient.cpp.

HTTPResult post ( const char *  url,
const IHTTPDataOut dataOut,
IHTTPDataIn pDataIn,
int  timeout = HTTP_CLIENT_DEFAULT_TIMEOUT 
)

Execute a POST request on the URL Blocks until completion.

Parameters:
url: url on which to execute the request
dataOut: a IHTTPDataOut instance that contains the data that will be posted
pDataIn: pointer to an IHTTPDataIn instance that will collect the data returned by the request, can be NULL
timeoutwaiting timeout in ms (osWaitForever for blocking function, not recommended)
Returns:
0 on success, HTTP error (<0) on failure

Definition at line 209 of file HTTPClient.cpp.

HTTPResult put ( const char *  url,
const IHTTPDataOut dataOut,
IHTTPDataIn pDataIn,
int  timeout = HTTP_CLIENT_DEFAULT_TIMEOUT 
)

Execute a PUT request on the URL Blocks until completion.

Parameters:
url: url on which to execute the request
dataOut: a IHTTPDataOut instance that contains the data that will be put
pDataIn: pointer to an IHTTPDataIn instance that will collect the data returned by the request, can be NULL
timeoutwaiting timeout in ms (osWaitForever for blocking function, not recommended)
Returns:
0 on success, HTTP error (<0) on failure

Definition at line 214 of file HTTPClient.cpp.