Minor tweaks to support longer header key value pairs

Dependents:   Car_Bon_car_module

Fork of HTTPClient by David Smart

Revision:
22:f6a3fcf48751
Parent:
21:d33f7e1ce811
Child:
23:96a9385ceeb6
--- a/HTTPClient.cpp	Sun Feb 09 22:25:28 2014 +0000
+++ b/HTTPClient.cpp	Fri Mar 14 20:03:23 2014 +0000
@@ -140,8 +140,8 @@
 
     char scheme[8];
     uint16_t port;
-    char host[32];
-    char path[64];
+    char host[48];
+    char path[96];
     //First we need to parse the url (http[s]://host[:port][/[path]]) -- HTTPS not supported (yet?)
     HTTPResult res = parseURL(url, scheme, sizeof(scheme), host, sizeof(host), &port, path, sizeof(path));
     if(res != HTTP_OK) {
@@ -169,7 +169,7 @@
 
     //Send request
     DBG("Sending request");
-    char buf[CHUNK_SIZE];
+    char buf[CHUNK_SIZE+1];
     const char* meth = (method==HTTP_GET)?"GET":(method==HTTP_POST)?"POST":(method==HTTP_PUT)?"PUT":(method==HTTP_DELETE)?"DELETE":"";
     snprintf(buf, sizeof(buf), "%s %s HTTP/1.1\r\nHost: %s:%d\r\nConnection: keep-alive\r\n", meth, path, host, port); //Write request
     ret = send(buf);
@@ -336,13 +336,13 @@
 
         buf[crlfPos] = '\0';
 
-        char key[32];
-        char value[32];
+        char key[40];
+        char value[40];
 
         key[31] = '\0';
         value[31] = '\0';
 
-        int n = sscanf(buf, "%31[^:]: %31[^\r\n]", key, value);
+        int n = sscanf(buf, "%35[^:]: %35[^\r\n]", key, value);
         if ( n == 2 ) {
             DBG("Read header : %s: %s\n", key, value);
             if( !strcmp(key, "Content-Length") ) {