![]() |
WiConnect Host Library- API Reference Guide | ||
HTTP methods. More...
Functions | |
WiconnectResult | wiconnect::SocketInterface::httpConnect (WiconnectSocket &socket, const char *url, const HttpSocketArgs *args) |
Connect to remote HTTP server. More... | |
WiconnectResult | wiconnect::SocketInterface::httpGet (WiconnectSocket &socket, const char *url, bool openOnly=false, const char *certFilename=NULL) |
Issue HTTP GET Request. More... | |
WiconnectResult | wiconnect::SocketInterface::httpPost (WiconnectSocket &socket, const char *url, const char *contextType, bool openOnly=true, const char *certFilename=NULL) |
Issue HTTP POST Request. More... | |
WiconnectResult | wiconnect::SocketInterface::httpHead (WiconnectSocket &socket, const char *url, const char *certFilename=NULL) |
Issue HTTP HEAD Request. More... | |
WiconnectResult | wiconnect::SocketInterface::httpAddHeader (WiconnectSocket &socket, const char *key, const char *value) |
Add HTTP header key/value pair to opened HTTP request. More... | |
WiconnectResult | wiconnect::SocketInterface::httpGetStatus (WiconnectSocket &socket, uint32_t *statusCodePtr) |
Get the HTTP status code from HTTP request. More... | |
HTTP methods.
WiconnectResult wiconnect::SocketInterface::httpAddHeader | ( | WiconnectSocket & | socket, |
const char * | key, | ||
const char * | value | ||
) |
Add HTTP header key/value pair to opened HTTP request.
To use this function, the supplied WiconnectSocket parameter must have been created using either httpGet() or httpPost() and the 'openOnly' parameter TRUE.
This will add additional header to the HTTP request.
Use httpGetStatus() to issue the request.
[in] | socket | Opened socket to add additonal HTTP header |
[in] | key | Header key (e.g. 'content-type') |
[in] | value | Header value (e.g. 'application/json') |
WiconnectResult wiconnect::SocketInterface::httpConnect | ( | WiconnectSocket & | socket, |
const char * | url, | ||
const HttpSocketArgs * | args | ||
) |
Connect to remote HTTP server.
This is the base method for the other HTTP methods.
Each HTTP method is able to connect to a secure HTTP server. To do this, the URL string parameter must start with 'https://' To connect to a secure HTTP server a TLS certificate is needed. The certificate is specified in the certFilename parameter of the method (or HttpSocketArgs parameter). This is the filename of an existing certificate on the module file system.
[out] | socket | HTTP WiconnectSocket object of opened connection. |
[in] | url | URL of HTTP request |
[in] | args | Configuration HttpSocketArgs for HTTP connection |
WiconnectResult wiconnect::SocketInterface::httpGet | ( | WiconnectSocket & | socket, |
const char * | url, | ||
bool | openOnly = false , |
||
const char * | certFilename = NULL |
||
) |
Issue HTTP GET Request.
This method has the open to only 'open' the connection (disabled by default). This means a connection to the remote HTTP server is opened, but the HTTP request isn't issued. This allow for addition data to be added to the request. For instance, use httpAddHeader() to add additional headers to the request. Use httpGetStatus() to issue the HTTP request and receive the HTTP response.
[out] | socket | HTTP WiconnectSocket object of opened connection. |
[in] | url | URL of HTTP GET request |
[in] | openOnly | Optional, if TRUE this will only open a connection to the server (it won't issue the request) |
[in] | certFilename | Optional, filename of existing TLS certificate on module's file system. See Secure HTTP |
WiconnectResult wiconnect::SocketInterface::httpGetStatus | ( | WiconnectSocket & | socket, |
uint32_t * | statusCodePtr | ||
) |
Get the HTTP status code from HTTP request.
This may be used to either issue an HTTP request of an opened HTTP connection or return the status code of a request already issued.
[in] | socket | Opened socket to get http response status code |
[out] | statusCodePtr | Pointer to uint32 to hold http status code |
WiconnectResult wiconnect::SocketInterface::httpHead | ( | WiconnectSocket & | socket, |
const char * | url, | ||
const char * | certFilename = NULL |
||
) |
Issue HTTP HEAD Request.
[out] | socket | HTTP WiconnectSocket object of opened connection. |
[in] | url | URL of HTTP HEAD request |
[in] | certFilename | Optional, filename of existing TLS certificate on module's file system. See Secure HTTP |
WiconnectResult wiconnect::SocketInterface::httpPost | ( | WiconnectSocket & | socket, |
const char * | url, | ||
const char * | contextType, | ||
bool | openOnly = true , |
||
const char * | certFilename = NULL |
||
) |
Issue HTTP POST Request.
This method has the open to only 'open' the connection which enabled by default. This means a connection to the remote HTTP server is opened, but the HTTP request isn't issued. This allow for addition data to be added to the request. Use the returned WiconnectSocket object's 'write' methods to add POST data to the request. When all POST data has been written, use httpGetStatus() to issue the HTTP request and receive the HTTP response.
[out] | socket | HTTP WiconnectSocket object of opened connection. |
[in] | url | URL of HTTP POST request |
[in] | contextType | The value to go into the 'content-type' HTTP header (e.g. 'application/json') |
[in] | openOnly | Optional, if FALSE this will immediately issue the POST request. |
[in] | certFilename | Optional, filename of existing TLS certificate on module's file system. See Secure HTTP |