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:
23:517fec8b8b99
Child:
32:7b9919d59194
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 #ifndef HTTPFILE_H
WiredHome 23:517fec8b8b99 2 #define HTTPFILE_H
WiredHome 25:76084defa790 3 #if 1
WiredHome 23:517fec8b8b99 4 #include <mbed.h>
WiredHome 23:517fec8b8b99 5 #include "../IHTTPData.h"
WiredHome 23:517fec8b8b99 6
WiredHome 23:517fec8b8b99 7
WiredHome 23:517fec8b8b99 8 class HTTPFile : public IHTTPDataIn {
WiredHome 23:517fec8b8b99 9
WiredHome 23:517fec8b8b99 10 public:
WiredHome 23:517fec8b8b99 11 HTTPFile(char* filename);
WiredHome 23:517fec8b8b99 12
WiredHome 23:517fec8b8b99 13 /** Closes the file, should be called once the http connection is closed.
WiredHome 23:517fec8b8b99 14 */
WiredHome 23:517fec8b8b99 15 void close();
WiredHome 23:517fec8b8b99 16
WiredHome 23:517fec8b8b99 17 protected:
WiredHome 23:517fec8b8b99 18
WiredHome 23:517fec8b8b99 19 friend class HTTPClient;
WiredHome 23:517fec8b8b99 20
WiredHome 23:517fec8b8b99 21 /** Reset stream to its beginning
WiredHome 23:517fec8b8b99 22 * Called by the HTTPClient on each new request
WiredHome 23:517fec8b8b99 23 */
WiredHome 23:517fec8b8b99 24 virtual void writeReset();
WiredHome 23:517fec8b8b99 25
WiredHome 23:517fec8b8b99 26 /** Write a piece of data transmitted by the server
WiredHome 23:517fec8b8b99 27 * @param buf Pointer to the buffer from which to copy the data
WiredHome 23:517fec8b8b99 28 * @param len Length of the buffer
WiredHome 23:517fec8b8b99 29 */
WiredHome 23:517fec8b8b99 30 virtual int write(const char* buf, size_t len);
WiredHome 23:517fec8b8b99 31
WiredHome 23:517fec8b8b99 32 /** Set MIME type
WiredHome 23:517fec8b8b99 33 * @param type Internet media type from Content-Type header
WiredHome 23:517fec8b8b99 34 */
WiredHome 23:517fec8b8b99 35 virtual void setDataType(const char* type);
WiredHome 23:517fec8b8b99 36
WiredHome 23:517fec8b8b99 37 /** Determine whether the data is chunked
WiredHome 23:517fec8b8b99 38 * Recovered from Transfer-Encoding header
WiredHome 23:517fec8b8b99 39 */
WiredHome 23:517fec8b8b99 40 virtual void setIsChunked(bool chunked);
WiredHome 23:517fec8b8b99 41
WiredHome 23:517fec8b8b99 42 /** If the data is not chunked, set its size
WiredHome 23:517fec8b8b99 43 * From Content-Length header
WiredHome 23:517fec8b8b99 44 */
WiredHome 23:517fec8b8b99 45 virtual void setDataLen(size_t len);
WiredHome 23:517fec8b8b99 46 private:
WiredHome 23:517fec8b8b99 47 FILE *file;
WiredHome 23:517fec8b8b99 48 size_t m_len;
WiredHome 23:517fec8b8b99 49 bool m_chunked;
WiredHome 23:517fec8b8b99 50 };
WiredHome 23:517fec8b8b99 51 #endif
WiredHome 25:76084defa790 52 #endif // HTTPFILE_H