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.

data/HTTPFile.cpp

Committer:
WiredHome
Date:
2014-03-23
Revision:
25:76084defa790
Parent:
24:eee214e3e806
Child:
27:32a53068ce03

File content as of revision 25:76084defa790:

#include "HTTPFile.h"
#if 1
HTTPFile::HTTPFile(char* filename) {
    file = fopen(filename, "w");    
}

void HTTPFile::close() {
    if (file) {
        fclose(file);    
    }        
}

void HTTPFile::writeReset() {
    if (file) {
        rewind(file);   
    }
}

int HTTPFile::write(const char* buf, size_t len) {
    if (file) {
        len = fwrite(&buf, 1, len, file);    
        if ((!m_chunked && (ftell(file) >= m_len)) || (m_chunked && !len)) {
            close();
        }
    }
    return len;    
}

void HTTPFile::setDataType(const char* type) {

}

//void HTTPFile::setLocation(const char * location) {
//
//}

void HTTPFile::setIsChunked(bool chunked) {
    m_chunked = chunked;
}

void HTTPFile::setDataLen(size_t len) {
    m_len = len;
}
#endif