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.
Fork of HTTPClient by
Revision 17:81d38e7522ca, committed 2014-04-28
- Comitter:
- olympux
- Date:
- Mon Apr 28 20:15:40 2014 +0000
- Parent:
- 16:1f743885e7de
- Commit message:
- Send X-ApiKey header
Changed in this revision
HTTPClient.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/HTTPClient.cpp Thu Aug 30 15:38:57 2012 +0000 +++ b/HTTPClient.cpp Mon Apr 28 20:15:40 2014 +0000 @@ -18,7 +18,7 @@ */ //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__); @@ -126,8 +126,8 @@ char scheme[8]; uint16_t port; - char host[32]; - char path[64]; + char host[32]; // default is 32 + char path[64]; // default is 64 //First we need to parse the url (http[s]://host[:port][/[path]]) -- HTTPS not supported (yet?) HTTPResult res = parseURL(url, scheme, sizeof(scheme), host, sizeof(host), &port, path, sizeof(path)); if(res != HTTP_OK) @@ -173,6 +173,7 @@ //Send default headers DBG("Sending headers"); + send("X-ApiKey: DcO8pnBiF4N0xyT9cPeQLggUHuNu7g8dwYhxH6s1qjZwtZm5\r\n"); if( pDataOut != NULL ) { if( pDataOut->getIsChunked() ) @@ -196,9 +197,9 @@ } //Close headers - DBG("Headers sent"); ret = send("\r\n"); CHECK_CONN_ERR(ret); + DBG("Headers sent"); size_t trfLen; @@ -247,7 +248,6 @@ break; } } - } //Receive response @@ -278,6 +278,7 @@ { //Did not return a 2xx code; TODO fetch headers/(&data?) anyway and implement a mean of writing/reading headers WARN("Response code %d", m_httpResponseCode); + DBG("Response: %s%",buf); PRTCL_ERR(); } @@ -546,6 +547,7 @@ len = strlen(buf); } DBG("Trying to write %d bytes", len); + DBG("%s", buf); size_t writtenLen = 0; if(!m_sock.is_connected()) @@ -585,6 +587,7 @@ return HTTP_PARSE; //URL is invalid } + DBG("%s",host); if( maxSchemeLen < hostPtr - schemePtr + 1 ) //including NULL-terminating char { WARN("Scheme str is too small (%d >= %d)", maxSchemeLen, hostPtr - schemePtr + 1);