Fork with custom headers and basic auth.

Dependents:   MbedSmartRest

Fork of HTTPClient by Kazushi Mukaiyama

Revision:
22:967c00d70d95
Parent:
21:66f1c10a5e9a
Child:
23:9386b15b0820
--- a/HTTPClient.cpp	Thu Jan 30 11:47:09 2014 +0000
+++ b/HTTPClient.cpp	Sun Feb 02 16:40:08 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__); 
@@ -40,7 +40,7 @@
 #define MIN(x,y) (((x)<(y))?(x):(y))
 #define MAX(x,y) (((x)>(y))?(x):(y))
 
-#define CHUNK_SIZE 256
+#define CHUNK_SIZE 128
 
 #include <cstring>
 
@@ -181,24 +181,14 @@
     strcat(buf, "\r\n");
     
     ret = send(buf);
-    if(ret)
-    {
-      m_sock.close();
-      ERR("Could not write request");
-      return HTTP_CONN;
-    }
+    CHECK_CONN_ERR(ret);
   }
 
   //Send all headers
   for (size_t nh = 0; nh < m_nCustomHeaders; ++nh) {
     snprintf(buf, sizeof(buf), "%s: %s\r\n", m_customHeaders[nh], m_customHeaders[nh+1]);
     ret = send(buf);
-    if(ret)
-    {
-      m_sock.close();
-      ERR("Could not write request");
-      return HTTP_CONN;
-    }
+    CHECK_CONN_ERR(ret);
   }
 
   //Send default headers
@@ -212,7 +202,7 @@
     }
     else
     {
-      snprintf(buf, sizeof(buf), "Content-Length: %d\r\n", pDataOut->getDataLen());
+      snprintf(buf, sizeof(buf), "Content-Length: %lu\r\n", pDataOut->getDataLen());
       ret = send(buf);
       CHECK_CONN_ERR(ret);
     }