smd.iotkit2.ch / Mbed 2 deprecated 2-10-02-Uebung

Dependencies:   EthernetInterface MbedJSONValue NTPClient mbed-rtos mbed

Fork of SunriseSunset by smd.iotkit2.ch

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HTTPFile.h Source File

HTTPFile.h

00001 #ifndef HTTPFILE_H
00002 #define HTTPFILE_H
00003 #if 1
00004 #include <mbed.h>
00005 #include "../IHTTPData.h"
00006 
00007 
00008 class HTTPFile : public IHTTPDataIn {
00009     
00010     public:
00011         HTTPFile(char* filename);
00012         
00013         /** Closes the file, should be called once the http connection is closed.
00014          */
00015         void close();
00016         
00017     protected:     
00018        
00019         friend class HTTPClient;
00020     
00021         /** Reset stream to its beginning 
00022         * Called by the HTTPClient on each new request
00023         */
00024         virtual void writeReset();
00025         
00026         /** Write a piece of data transmitted by the server
00027         * @param[in] buf Pointer to the buffer from which to copy the data
00028         * @param[in] len Length of the buffer
00029         * @returns number of bytes written.
00030         */
00031         virtual int write(const char* buf, size_t len);
00032         
00033         /** Set MIME type
00034         * @param[in] type Internet media type from Content-Type header
00035         */
00036         virtual void setDataType(const char* type);
00037         
00038         /** Determine whether the data is chunked
00039         *  Recovered from Transfer-Encoding header
00040         * @param[in] chunked indicates the transfer is chunked.
00041         */
00042         virtual void setIsChunked(bool chunked);
00043         
00044         /** If the data is not chunked, set its size
00045         * From Content-Length header
00046         * @param[in] len defines the size of the non-chunked transfer.
00047         */
00048         virtual void setDataLen(size_t len);
00049     private:
00050         FILE *file;
00051         size_t m_len;
00052         bool m_chunked;
00053 };
00054 #endif
00055 #endif  // HTTPFILE_H