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.

Committer:
WiredHome
Date:
Sat Mar 15 22:18:30 2014 +0000
Revision:
24:eee214e3e806
Parent:
23:517fec8b8b99
Child:
25:76084defa790
Reformatted to match standard style.; Added support for automatically following redirection, and for getting the redirect location.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 23:517fec8b8b99 1 #include "HTTPFile.h"
WiredHome 23:517fec8b8b99 2 #if 0
WiredHome 23:517fec8b8b99 3 HTTPFile::HTTPFile(char* filename) {
WiredHome 23:517fec8b8b99 4 file = fopen(filename, "w");
WiredHome 23:517fec8b8b99 5 }
WiredHome 23:517fec8b8b99 6
WiredHome 23:517fec8b8b99 7 void HTTPFile::close() {
WiredHome 23:517fec8b8b99 8 if (file) {
WiredHome 23:517fec8b8b99 9 fclose(file);
WiredHome 23:517fec8b8b99 10 }
WiredHome 23:517fec8b8b99 11 }
WiredHome 23:517fec8b8b99 12
WiredHome 23:517fec8b8b99 13 void HTTPFile::writeReset() {
WiredHome 23:517fec8b8b99 14 if (file) {
WiredHome 23:517fec8b8b99 15 rewind(file);
WiredHome 23:517fec8b8b99 16 }
WiredHome 23:517fec8b8b99 17 }
WiredHome 23:517fec8b8b99 18
WiredHome 23:517fec8b8b99 19 int HTTPFile::write(const char* buf, size_t len) {
WiredHome 23:517fec8b8b99 20 if (file) {
WiredHome 23:517fec8b8b99 21 len = fwrite(&buf, 1, len, file);
WiredHome 23:517fec8b8b99 22 if ((!m_chunked && (ftell(file) >= m_len)) || (m_chunked && !len)) {
WiredHome 23:517fec8b8b99 23 close();
WiredHome 23:517fec8b8b99 24 }
WiredHome 23:517fec8b8b99 25 }
WiredHome 23:517fec8b8b99 26 return len;
WiredHome 23:517fec8b8b99 27 }
WiredHome 23:517fec8b8b99 28
WiredHome 23:517fec8b8b99 29 void HTTPFile::setDataType(const char* type) {
WiredHome 23:517fec8b8b99 30
WiredHome 23:517fec8b8b99 31 }
WiredHome 23:517fec8b8b99 32
WiredHome 24:eee214e3e806 33 void HTTPFile::setLocation(const char * location) {
WiredHome 24:eee214e3e806 34
WiredHome 24:eee214e3e806 35 }
WiredHome 24:eee214e3e806 36
WiredHome 23:517fec8b8b99 37 void HTTPFile::setIsChunked(bool chunked) {
WiredHome 23:517fec8b8b99 38 m_chunked = chunked;
WiredHome 23:517fec8b8b99 39 }
WiredHome 23:517fec8b8b99 40
WiredHome 23:517fec8b8b99 41 void HTTPFile::setDataLen(size_t len) {
WiredHome 23:517fec8b8b99 42 m_len = len;
WiredHome 23:517fec8b8b99 43 }
WiredHome 23:517fec8b8b99 44 #endif