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:
36:a5c13e512b78
Parent:
16:1f743885e7de
--- a/data/HTTPText.cpp	Thu Aug 06 11:11:31 2015 +0000
+++ b/data/HTTPText.cpp	Tue Jan 26 11:44:35 2016 +0000
@@ -31,7 +31,7 @@
 
 HTTPText::HTTPText(char* str) : m_str(str), m_pos(0)
 {
-  m_size = strlen(str) + 1;
+    m_size = strlen(str) + 1;
 }
 
 HTTPText::HTTPText(char* str, size_t size) : m_str(str), m_size(size), m_pos(0)
@@ -42,47 +42,47 @@
 //IHTTPDataIn
 /*virtual*/ void HTTPText::readReset()
 {
-  m_pos = 0;
+    m_pos = 0;
 }
 
 /*virtual*/ int HTTPText::read(char* buf, size_t len, size_t* pReadLen)
 {
-  *pReadLen = MIN(len, m_size - 1 - m_pos);
-  memcpy(buf, m_str + m_pos, *pReadLen);
-  m_pos += *pReadLen;
-  return OK;
+    *pReadLen = MIN(len, m_size - 1 - m_pos);
+    memcpy(buf, m_str + m_pos, *pReadLen);
+    m_pos += *pReadLen;
+    return OK;
 }
 
 /*virtual*/ int HTTPText::getDataType(char* type, size_t maxTypeLen) //Internet media type for Content-Type header
 {
-  strncpy(type, "text/plain", maxTypeLen-1);
-  type[maxTypeLen-1] = '\0';
-  return OK;
+    strncpy(type, "text/plain", maxTypeLen-1);
+    type[maxTypeLen-1] = '\0';
+    return OK;
 }
 
 /*virtual*/ bool HTTPText::getIsChunked() //For Transfer-Encoding header
 {
-  return false;
+    return false;
 }
 
 /*virtual*/ size_t HTTPText::getDataLen() //For Content-Length header
 {
-  return m_size - 1;
+    return m_size - 1;
 }
 
 //IHTTPDataOut
 /*virtual*/ void HTTPText::writeReset()
 {
-  m_pos = 0;
+    m_pos = 0;
 }
 
 /*virtual*/ int HTTPText::write(const char* buf, size_t len)
 {
-  size_t writeLen = MIN(len, m_size - 1 - m_pos);
-  memcpy(m_str + m_pos, buf, writeLen);
-  m_pos += writeLen;
-  m_str[m_pos] = '\0';
-  return OK;
+    size_t writeLen = MIN(len, m_size - 1 - m_pos);
+    memcpy(m_str + m_pos, buf, writeLen);
+    m_pos += writeLen;
+    m_str[m_pos] = '\0';
+    return OK;
 }
 
 /*virtual*/ void HTTPText::setDataType(const char* type) //Internet media type from Content-Type header