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 */
Revision 13:be61104f4e91, committed 2012-08-05
- Comitter:
- donatien
- Date:
- Sun Aug 05 16:12:10 2012 +0000
- Parent:
- 12:89d09a6db00a
- Child:
- 14:2744e0c0e527
- Commit message:
- Fixed blocking mode
Changed in this revision
--- a/HTTPClient.cpp Sun Aug 05 15:30:07 2012 +0000 +++ b/HTTPClient.cpp Sun Aug 05 16:12:10 2012 +0000 @@ -18,10 +18,11 @@ */ //Debug is disabled by default -#if 0 +#if 1 //Enable debug #include <cstdio> -#define DBG(x, ...) std::printf("[HTTPClient : DBG]"x"\r\n", ##__VA_ARGS__); +//#define DBG(x, ...) std::printf("[HTTPClient : DBG]"x"\r\n", ##__VA_ARGS__); +#define DBG(x, ...) #define WARN(x, ...) std::printf("[HTTPClient : WARN]"x"\r\n", ##__VA_ARGS__); #define ERR(x, ...) std::printf("[HTTPClient : ERR]"x"\r\n", ##__VA_ARGS__); @@ -470,13 +471,13 @@ if(readLen < minLen) { DBG("Trying to read at most %d bytes [Blocking]", minLen - readLen); - m_sock.set_blocking(true, m_timeout); + m_sock.set_blocking(false, m_timeout); ret = m_sock.receive_all(buf + readLen, minLen - readLen); } else { DBG("Trying to read at most %d bytes [Not blocking]", maxLen - readLen); - m_sock.set_blocking(false); + m_sock.set_blocking(false, 0); ret = m_sock.receive(buf + readLen, maxLen - readLen); } @@ -527,7 +528,7 @@ return HTTP_CLOSED; //Connection was closed by server } - m_sock.set_blocking(true, m_timeout); + m_sock.set_blocking(false, m_timeout); int ret = m_sock.send_all(buf, len); if(ret > 0) {
--- a/IHTTPData.h Sun Aug 05 15:30:07 2012 +0000 +++ b/IHTTPData.h Sun Aug 05 16:12:10 2012 +0000 @@ -20,6 +20,10 @@ #ifndef IHTTPDATA_H #define IHTTPDATA_H +#include <cstring> + +using std::size_t; + ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...) class IHTTPDataOut {
--- a/data/HTTPMap.cpp Sun Aug 05 15:30:07 2012 +0000 +++ b/data/HTTPMap.cpp Sun Aug 05 16:12:10 2012 +0000 @@ -17,14 +17,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "core/fwk.h" - #include "HTTPMap.h" #include <cstring> #include <cctype> +#define OK 0 + +using std::strncpy; + HTTPMap::HTTPMap() : m_pos(0), m_count(0) {
--- a/data/HTTPText.cpp Sun Aug 05 15:30:07 2012 +0000 +++ b/data/HTTPText.cpp Sun Aug 05 16:12:10 2012 +0000 @@ -17,12 +17,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "core/fwk.h" - #include "HTTPText.h" #include <cstring> +#define OK 0 + +using std::memcpy; +using std::strncpy; +using std::strlen; + +#define MIN(x,y) (((x)<(y))?(x):(y)) + HTTPText::HTTPText(char* str) : m_str(str), m_pos(0) { m_size = strlen(str) + 1;