A HTTP/HTTPS Client for the mbed networking/CyaSSL ssl library
Dependents: Anpi dropbox_access php_access_auth TwitterReader ... more
Fork of HTTPClient by
HTTP and HTTPS Client Class with wolfSSL, embedded SSL library.
The class was forked from http://mbed.org/users/donatien/code/HTTPClient/
It, now, accepts url both with "http://" and "https://".
Allocate caller thread with 16kbytes or larger stack for "https" requests.
Rest of the API stays compatible with HTTPClient.
For more about the library, see http://www.wolfssl.com. http://wolfssl.com/yaSSL/Docs.html.
Extended methods:
- HTTPResult basicAuth(const char* user, const char* password); /* set id/passwd for basic Authentication */
- void setHeader(char *header) ; /* set http headers */
- HTTPResult setSSLversion(int minorV) ; /* set SSL/TLS version. 0: SSL3, 1: TLS1.0, 2: TLS1.1, 3: TLS1.2 */
Diff: HTTPClient.h
- Revision:
- 11:390362de8c3f
- Parent:
- 10:e1351de84c16
- Child:
- 12:89d09a6db00a
--- a/HTTPClient.h Wed Jul 18 15:40:04 2012 +0000 +++ b/HTTPClient.h Mon Jul 30 15:16:51 2012 +0000 @@ -24,7 +24,7 @@ #ifndef HTTP_CLIENT_H #define HTTP_CLIENT_H -#include "TCPSocket.h" +#include "TCPSocketConnection.h" #define HTTP_CLIENT_DEFAULT_TIMEOUT 4000 @@ -36,7 +36,6 @@ ///HTTP client results enum HTTPResult { - HTTP_OK, ///<Success HTTP_PROCESSING, ///<Processing HTTP_PARSE, ///<url Parse error HTTP_DNS, ///<Could not resolve name @@ -45,7 +44,9 @@ HTTP_REFUSED, ///<HTTP 403 Error HTTP_ERROR, ///<HTTP xxx error HTTP_TIMEOUT, ///<Connection timeout - HTTP_CONN ///<Connection error + HTTP_CONN, ///<Connection error + HTTP_CLOSED, ///<Connection was closed by remote host + HTTP_OK = 0, ///<Success }; /**A simple HTTP Client @@ -78,7 +79,7 @@ @param timeout waiting timeout in ms (osWaitForever for blocking function, not recommended) @return 0 on success, NET error (<0) on failure */ - int get(const char* url, IHTTPDataIn* pDataIn, uint32_t timeout = HTTP_CLIENT_DEFAULT_TIMEOUT); //Blocking + HTTPResult get(const char* url, IHTTPDataIn* pDataIn, uint32_t timeout = HTTP_CLIENT_DEFAULT_TIMEOUT); //Blocking /** Execute a GET request on the url Blocks until completion @@ -89,7 +90,7 @@ @param timeout waiting timeout in ms (osWaitForever for blocking function, not recommended) @return 0 on success, NET error on failure */ - int get(const char* url, char* result, size_t maxResultLen, uint32_t timeout = HTTP_CLIENT_DEFAULT_TIMEOUT); //Blocking + HTTPResult get(const char* url, char* result, size_t maxResultLen, uint32_t timeout = HTTP_CLIENT_DEFAULT_TIMEOUT); //Blocking /** Execute a POST request on the url Blocks until completion @@ -99,7 +100,7 @@ @param timeout waiting timeout in ms (osWaitForever for blocking function, not recommended) @return 0 on success, NET error on failure */ - int post(const char* url, const IHTTPDataOut& dataOut, IHTTPDataIn* pDataIn, uint32_t timeout = HTTP_CLIENT_DEFAULT_TIMEOUT); //Blocking + HTTPResult post(const char* url, const IHTTPDataOut& dataOut, IHTTPDataIn* pDataIn, uint32_t timeout = HTTP_CLIENT_DEFAULT_TIMEOUT); //Blocking /** Get last request's HTTP response code @return The HTTP response code of the last request @@ -114,13 +115,13 @@ HTTP_HEAD }; - int connect(const char* url, HTTP_METH method, IHTTPDataOut* pDataOut, IHTTPDataIn* pDataIn, uint32_t timeout); //Execute request - int recv(char* buf, size_t minLen, size_t maxLen, size_t* pReadLen); //0 on success, err code on failure - int send(char* buf, size_t len = 0); //0 on success, err code on failure - int parseURL(const char* url, char* scheme, size_t maxSchemeLen, char* host, size_t maxHostLen, uint16_t* port, char* path, size_t maxPathLen); //Parse URL + HTTPResult connect(const char* url, HTTP_METH method, IHTTPDataOut* pDataOut, IHTTPDataIn* pDataIn, uint32_t timeout); //Execute request + HTTPResult recv(char* buf, size_t minLen, size_t maxLen, size_t* pReadLen); //0 on success, err code on failure + HTTPResult send(char* buf, size_t len = 0); //0 on success, err code on failure + HTTPResult parseURL(const char* url, char* scheme, size_t maxSchemeLen, char* host, size_t maxHostLen, uint16_t* port, char* path, size_t maxPathLen); //Parse URL //Parameters - TCPSocket m_sock; + TCPSocketConnection m_sock; uint32_t m_timeout;