Fixed HTTP header key and value length.

Dependents:   SNIC-httpclient-example HTTPClient_HelloWorld

Fork of HTTPClient by Donatien Garnier

Files at this revision

API Documentation at this revision

Comitter:
ban4jp
Date:
Sun Oct 12 16:00:13 2014 +0000
Parent:
18:277279a1891e
Child:
20:f020c92bd1a2
Commit message:
Fixed: HTTP header key and value length. [to 32 => 34]; (eg: Access-Control-Allow-Credentials:true )

Changed in this revision

HTTPClient.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/HTTPClient.cpp	Wed May 07 16:48:10 2014 +0000
+++ b/HTTPClient.cpp	Sun Oct 12 16:00:13 2014 +0000
@@ -41,6 +41,8 @@
 #define MAX(x,y) (((x)>(y))?(x):(y))
 
 #define CHUNK_SIZE 256
+#define HEADER_KEY_MAXLENGTH   34
+#define HEADER_VALUE_MAXLENGTH 34
 
 #include <cstring>
 
@@ -364,14 +366,14 @@
 
     buf[crlfPos] = '\0';
 
-    char key[32];
-    char value[32];
+    char key[HEADER_KEY_MAXLENGTH];
+    char value[HEADER_VALUE_MAXLENGTH];
 
     //key[31] = '\0';
     //value[31] = '\0';
 
-    memset(key, 0, 32);
-    memset(value, 0, 32);
+    memset(key, 0, HEADER_KEY_MAXLENGTH);
+    memset(value, 0, HEADER_VALUE_MAXLENGTH);
 
     //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) < HEADER_KEY_MAXLENGTH)
       {
         strcpy(key, buf);
         n++;
         char* valueStart = keyEnd + 2;
         if( (valueStart - buf) < crlfPos )
         {
-          if(strlen(valueStart) < 32)
+          if(strlen(valueStart) < HEADER_VALUE_MAXLENGTH)
           { 
             strcpy(value, valueStart);
             n++;