Fork HTTPClient and Modfiy code for mbed 6.0

Dependents:   mbed-demo-http-get-json

Committer:
WiredHome
Date:
Sat Oct 11 17:26:04 2014 +0000
Revision:
32:7b9919d59194
Parent:
25:76084defa790
Child:
33:d4d1475bafc0
Documentation updates only.

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 32:7b9919d59194 27 * @param[in] buf Pointer to the buffer from which to copy the data
WiredHome 32:7b9919d59194 28 * @param[in] len Length of the buffer
WiredHome 32:7b9919d59194 29 * @returns number of bytes written.
WiredHome 23:517fec8b8b99 30 */
WiredHome 23:517fec8b8b99 31 virtual int write(const char* buf, size_t len);
WiredHome 23:517fec8b8b99 32
WiredHome 23:517fec8b8b99 33 /** Set MIME type
WiredHome 32:7b9919d59194 34 * @param[in] type Internet media type from Content-Type header
WiredHome 23:517fec8b8b99 35 */
WiredHome 23:517fec8b8b99 36 virtual void setDataType(const char* type);
WiredHome 23:517fec8b8b99 37
WiredHome 23:517fec8b8b99 38 /** Determine whether the data is chunked
WiredHome 23:517fec8b8b99 39 * Recovered from Transfer-Encoding header
WiredHome 32:7b9919d59194 40 * @param[in] chunked indicates the transfer is chunked.
WiredHome 23:517fec8b8b99 41 */
WiredHome 23:517fec8b8b99 42 virtual void setIsChunked(bool chunked);
WiredHome 23:517fec8b8b99 43
WiredHome 23:517fec8b8b99 44 /** If the data is not chunked, set its size
WiredHome 23:517fec8b8b99 45 * From Content-Length header
WiredHome 32:7b9919d59194 46 * @param[in] len defines the size of the non-chunked transfer.
WiredHome 23:517fec8b8b99 47 */
WiredHome 23:517fec8b8b99 48 virtual void setDataLen(size_t len);
WiredHome 23:517fec8b8b99 49 private:
WiredHome 23:517fec8b8b99 50 FILE *file;
WiredHome 23:517fec8b8b99 51 size_t m_len;
WiredHome 23:517fec8b8b99 52 bool m_chunked;
WiredHome 23:517fec8b8b99 53 };
WiredHome 23:517fec8b8b99 54 #endif
WiredHome 25:76084defa790 55 #endif // HTTPFILE_H