Fork of the working HTTPClient adaptation using CyaSSL. This version adds a derivation of HTTPText called HTTPJson to emit JSON text properly. Additionally, the URL parser has defines that permit longer URLs to be utilized.

Dependencies:   mbedTLSLibrary

Dependents:   SalesforceInterface df-2014-heroku-thermostat-k64f SalesforceInterface

Fork of HTTPClient by wolf SSL

This is a fork of the working HTTPS/SSL library that contains two extensions:

- HTTPJson - a derivation of HTTPText for emitting JSON strings specifically. No JSON parsing/checking is accomplished - HTTPJson simply sets the right Content-Type for HTTP(S).

- Expanded internal buffers for longer URLs. This is set in HTTPClient.cpp and is tunable.

Files at this revision

API Documentation at this revision

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

HTTPClient.cpp Show annotated file Show diff for this revision Revisions of this file
IHTTPData.h Show annotated file Show diff for this revision Revisions of this file
data/HTTPMap.cpp Show annotated file Show diff for this revision Revisions of this file
data/HTTPText.cpp Show annotated file Show diff for this revision Revisions of this file
--- 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;