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:
43:12a6ae712bcd
Parent:
42:ab259a9d1d36
Child:
44:0e3b0849b2c7
--- a/HTTPClient.cpp	Sun Jun 04 15:51:38 2017 +0000
+++ b/HTTPClient.cpp	Thu Jul 20 10:56:03 2017 +0000
@@ -126,7 +126,7 @@
 
 HTTPResult HTTPClient::get(const char* url, char* result, size_t maxResultLen, int timeout /*= HTTP_CLIENT_DEFAULT_TIMEOUT*/) //Blocking
 {
-    INFO("url: %s, timeout: %d", url, timeout);
+    INFO("url: %s, maxResultLen %d, timeout: %d", url, maxResultLen, timeout);
     HTTPText str(result, maxResultLen);
     return get(url, &str, timeout);
 }
@@ -512,6 +512,7 @@
             if(readLen) {
                 ret = recv(buf, 1, CHUNK_SIZE - trfLen - 1, &trfLen);
                 CHECK_CONN_ERR(ret);
+                INFO("recv'd next chunk ret: %d", ret);
             }
         } while(readLen);
 
@@ -523,6 +524,7 @@
                 ret = recv(buf + trfLen, 2 - trfLen, CHUNK_SIZE - trfLen - 1, &newTrfLen);
                 CHECK_CONN_ERR(ret);
                 trfLen += newTrfLen;
+                INFO("recv'd next chunk ret: %d", ret);
             }
             if( (buf[0] != '\r') || (buf[1] != '\n') ) {
                 ERR("Format error");
@@ -533,12 +535,9 @@
         } else {
             break;
         }
-
     }
-
     m_sock.close();
     DBG("Completed HTTP transaction");
-
     return HTTP_OK;
 }
 
@@ -620,14 +619,14 @@
 {
     char* schemePtr = (char*) url;
     char* hostPtr = (char*) strstr(url, "://");
-    INFO("parseURL(%s,%s,%d,%s,%d,%d,%s,%d",
+    INFO("parseURL(%s,%p,%d,%s,%d,%d,%p,%d",
         url, scheme, maxSchemeLen, host, maxHostLen, *port, path, maxPathLen);
-    if(hostPtr == NULL) {
+    if (hostPtr == NULL) {
         WARN("Could not find host");
         return HTTP_PARSE; //URL is invalid
     }
 
-    if( (uint16_t)maxSchemeLen < hostPtr - schemePtr + 1 ) { //including NULL-terminating char
+    if ( (uint16_t)maxSchemeLen < hostPtr - schemePtr + 1 ) { //including NULL-terminating char
         WARN("Scheme str is too small (%d >= %d)", maxSchemeLen, hostPtr - schemePtr + 1);
         return HTTP_PARSE;
     }