Fixed custom headers and Basic authorization, added support for redirection, functional file download interface can be used for SW updates and more.

Dependents:   Sample_HTTPClient Sample_HTTPClient LWM2M_NanoService_Ethernet LWM2M_NanoService_Ethernet ... more

Fork of HTTPClient by Vincent Wochnik

More recent changes - added iCal processing.

Derivative of a derivative, however this one works when it comes to supplying Basic authorization to access a protected resource. Some additional changes to the debug interface to clean it up for consistency with many other components I have.

Revision:
29:9ee96efc1c20
Parent:
28:c0c7a6321f84
Child:
31:96da7c08b5d0
--- a/HTTPClient.cpp	Sat May 17 19:54:21 2014 +0000
+++ b/HTTPClient.cpp	Sat Jun 14 14:43:09 2014 +0000
@@ -393,7 +393,6 @@
 
                 memmove(buf, &buf[crlfPos+2], trfLen - (crlfPos + 2) + 1); //Be sure to move NULL-terminating char as well
                 trfLen -= (crlfPos + 2);
-
             } else {
                 ERR("Could not parse header");
                 PRTCL_ERR();
@@ -457,6 +456,7 @@
         DBG("Retrieving %d bytes", readLen);
 
         do {
+            INFO("write %d,%d: %s", trfLen, readLen, buf);
             pDataIn->write(buf, MIN(trfLen, readLen));
             if( trfLen > readLen ) {
                 memmove(buf, &buf[readLen], trfLen - readLen);
@@ -476,6 +476,7 @@
             if(trfLen < 2) {
                 size_t newTrfLen;
                 //Read missing chars to find end of chunk
+                INFO("read chunk");
                 ret = recv(buf + trfLen, 2 - trfLen, CHUNK_SIZE - trfLen - 1, &newTrfLen);
                 CHECK_CONN_ERR(ret);
                 trfLen += newTrfLen;
@@ -511,11 +512,11 @@
     int ret;
     while (readLen < maxLen) {
         if (readLen < minLen) {
-            DBG("Trying to read at most %d bytes [Blocking]", minLen - readLen);
+            DBG("Trying to read at most %4d bytes [Blocking] %d,%d", minLen - readLen, minLen, readLen);
             m_sock.set_blocking(false, m_timeout);
             ret = m_sock.receive_all(buf + readLen, minLen - readLen);
         } else {
-            DBG("Trying to read at most %d bytes [Not blocking]", maxLen - readLen);
+            DBG("Trying to read at most %4d bytes [Not blocking] %d,%d", maxLen - readLen, maxLen, readLen);
             m_sock.set_blocking(false, 0);
             ret = m_sock.receive(buf + readLen, maxLen - readLen);
         }
@@ -538,6 +539,7 @@
         }
     }
     DBG("Read %d bytes", readLen);
+    buf[readLen] = '\0';    // DS makes it easier to see what's new.
     *pReadLen = readLen;
     return HTTP_OK;
 }