Fork HTTPClient and Modfiy code for mbed 6.0

Dependents:   mbed-demo-http-get-json

Committer:
WiredHome
Date:
Sun Mar 23 20:40:05 2014 +0000
Revision:
25:76084defa790
Parent:
24:eee214e3e806
Child:
27:32a53068ce03
Corrected a defect where the count of custom headers was not initialized. This caused it to try to send <random> number of headers.; Also, enabled HTTPFile.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 23:517fec8b8b99 1 #include "HTTPFile.h"
WiredHome 25:76084defa790 2 #if 1
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 25:76084defa790 33 //void HTTPFile::setLocation(const char * location) {
WiredHome 25:76084defa790 34 //
WiredHome 25:76084defa790 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