fork httpClient

Fork of HTTPClient by Donatien Garnier

Revision:
19:50c849f8d2c1
Parent:
18:277279a1891e
--- a/HTTPClient.cpp	Wed May 07 16:48:10 2014 +0000
+++ b/HTTPClient.cpp	Tue Apr 14 13:27:56 2015 +0000
@@ -17,34 +17,22 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-//Debug is disabled by default
-#if 0
-//Enable debug
-#include <cstdio>
-#define DBG(x, ...) std::printf("[HTTPClient : DBG]"x"\r\n", ##__VA_ARGS__); 
-#define WARN(x, ...) std::printf("[HTTPClient : WARN]"x"\r\n", ##__VA_ARGS__); 
-#define ERR(x, ...) std::printf("[HTTPClient : ERR]"x"\r\n", ##__VA_ARGS__); 
+#include "HTTPClient.h"
 
-#else
-//Disable debug
-#define DBG(x, ...) 
-#define WARN(x, ...)
-#define ERR(x, ...) 
-
+#define __DEBUG__ 0
+#ifndef __MODULE__
+#define __MODULE__ "HTTPClient.cpp"
 #endif
+#include "MyDebug.h"
 
 #define HTTP_PORT 80
-
 #define OK 0
-
 #define MIN(x,y) (((x)<(y))?(x):(y))
 #define MAX(x,y) (((x)>(y))?(x):(y))
-
 #define CHUNK_SIZE 256
 
-#include <cstring>
-
-#include "HTTPClient.h"
+#define KEYLEN  64
+#define VALLEN  64
 
 HTTPClient::HTTPClient() :
 m_sock(), m_basicAuthUser(NULL), m_basicAuthPassword(NULL), m_httpResponseCode(0)
@@ -273,6 +261,8 @@
   CHECK_CONN_ERR(ret);
 
   buf[trfLen] = '\0';
+  
+  //DBG_MEMDUMP("rcv data",buf,trfLen);
 
   //Make sure we got the first response line
   char* crlfPtr = NULL;
@@ -364,14 +354,15 @@
 
     buf[crlfPos] = '\0';
 
-    char key[32];
-    char value[32];
+
+    char key[KEYLEN];
+    char value[VALLEN];
 
     //key[31] = '\0';
     //value[31] = '\0';
 
-    memset(key, 0, 32);
-    memset(value, 0, 32);
+    memset(key, 0, KEYLEN);
+    memset(value, 0, VALLEN);
 
     //int n = sscanf(buf, "%31[^:]: %31[^\r\n]", key, value);
     
@@ -381,14 +372,14 @@
     if(keyEnd != NULL)
     {
       *keyEnd = '\0';
-      if(strlen(buf) < 32)
+      if(strlen(buf) < KEYLEN)
       {
         strcpy(key, buf);
         n++;
         char* valueStart = keyEnd + 2;
         if( (valueStart - buf) < crlfPos )
         {
-          if(strlen(valueStart) < 32)
+          if(strlen(valueStart) < VALLEN)
           { 
             strcpy(value, valueStart);
             n++;