Fork HTTPClient and Modfiy code for mbed 6.0

Dependents:   mbed-demo-http-get-json

Revision:
31:96da7c08b5d0
Parent:
29:9ee96efc1c20
Child:
33:d4d1475bafc0
--- a/HTTPClient.cpp	Sat Jul 05 22:26:07 2014 +0000
+++ b/HTTPClient.cpp	Sat Jul 26 19:47:36 2014 +0000
@@ -40,6 +40,7 @@
 #define MAX(x,y) (((x)>(y))?(x):(y))
 
 #define CHUNK_SIZE 256
+#define MAXLEN_VALUE 120    /* Max URL and Max Value for Name:Value */
 
 #include <cstring>
 
@@ -150,7 +151,7 @@
     char scheme[8];
     uint16_t port;
     char host[32];
-    char path[64];
+    char path[MAXLEN_VALUE];
     size_t recvContentLength = 0;
     bool recvChunked = false;
     int crlfPos = 0;
@@ -193,6 +194,7 @@
         DBG("Sending request");
         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
+        INFO(" buf{%s}", buf);
         ret = send(buf);
         if (ret) {
             m_sock.close();
@@ -359,12 +361,12 @@
             buf[crlfPos] = '\0';
 
             char key[32];
-            char value[64];
+            char value[MAXLEN_VALUE];
 
             key[31] = '\0';
-            value[63] = '\0';
+            value[MAXLEN_VALUE - 1] = '\0';
 
-            int n = sscanf(buf, "%31[^:]: %63[^\r\n]", key, value);
+            int n = sscanf(buf, "%31[^:]: %160[^\r\n]", key, value);
             if ( n == 2 ) {
                 DBG("Read header : %s: %s", key, value);
                 if( !strcmp(key, "Content-Length") ) {