Change the CHUNK_SIZE, KEY_SIZE and VALUE_SIZE

Dependents:   CurrentWeatherData_W5500 EmailButton EmailButton HTTPClient_Weather ... more

Fork of HTTPClient by Donatien Garnier

Revision:
19:9ba72b4d7ffc
Parent:
18:277279a1891e
--- a/HTTPClient.cpp	Wed May 07 16:48:10 2014 +0000
+++ b/HTTPClient.cpp	Tue Sep 02 01:16:31 2014 +0000
@@ -40,7 +40,11 @@
 #define MIN(x,y) (((x)<(y))?(x):(y))
 #define MAX(x,y) (((x)>(y))?(x):(y))
 
-#define CHUNK_SIZE 256
+//#define CHUNK_SIZE 256
+#define CHUNK_SIZE 1024
+
+#define KEY_SIZE    64
+#define VALUE_SIZE  64
 
 #include <cstring>
 
@@ -278,25 +282,25 @@
   char* crlfPtr = NULL;
   while( true )
   {
-    crlfPtr = strstr(buf, "\r\n");
-  if(crlfPtr == NULL)
-  {
-      if( trfLen < CHUNK_SIZE - 1 )
+      crlfPtr = strstr(buf, "\r\n");
+      if(crlfPtr == NULL)
       {
-        size_t newTrfLen;
-        ret = recv(buf + trfLen, 1, CHUNK_SIZE - trfLen - 1, &newTrfLen);
-        trfLen += newTrfLen;
-        buf[trfLen] = '\0';
-        DBG("Read %d chars; In buf: [%s]", newTrfLen, buf);
-        CHECK_CONN_ERR(ret);
-        continue;
+          if( trfLen < CHUNK_SIZE - 1 )
+          {
+            size_t newTrfLen;
+            ret = recv(buf + trfLen, 1, CHUNK_SIZE - trfLen - 1, &newTrfLen);
+            trfLen += newTrfLen;
+            buf[trfLen] = '\0';
+            DBG("Read %d chars; In buf: [%s]", newTrfLen, buf);
+            CHECK_CONN_ERR(ret);
+            continue;
+          }
+          else
+          {
+              PRTCL_ERR();
+          }
       }
-      else
-      {
-    PRTCL_ERR();
-  }
-    }
-    break;
+      break;
   }
 
   int crlfPos = crlfPtr - buf;
@@ -327,6 +331,7 @@
   memmove(buf, &buf[crlfPos+2], trfLen - (crlfPos + 2) + 1); //Be sure to move NULL-terminating char as well
   trfLen -= (crlfPos + 2);
 
+
   size_t recvContentLength = 0;
   bool recvChunked = false;
   bool recvLengthUnknown = true;
@@ -364,14 +369,11 @@
 
     buf[crlfPos] = '\0';
 
-    char key[32];
-    char value[32];
+    char key[KEY_SIZE];
+    char value[VALUE_SIZE];
 
-    //key[31] = '\0';
-    //value[31] = '\0';
-
-    memset(key, 0, 32);
-    memset(value, 0, 32);
+    memset(key, 0, KEY_SIZE);
+    memset(value, 0, VALUE_SIZE);
 
     //int n = sscanf(buf, "%31[^:]: %31[^\r\n]", key, value);
     
@@ -381,14 +383,14 @@
     if(keyEnd != NULL)
     {
       *keyEnd = '\0';
-      if(strlen(buf) < 32)
+      if(strlen(buf) < VALUE_SIZE)
       {
         strcpy(key, buf);
         n++;
         char* valueStart = keyEnd + 2;
         if( (valueStart - buf) < crlfPos )
         {
-          if(strlen(valueStart) < 32)
+          if(strlen(valueStart) < VALUE_SIZE)
           { 
             strcpy(value, valueStart);
             n++;