Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface TMP175 mbed-rtos mbed
Fork of HTTP_POST by
HTTPClient/data/HTTPFile.h@14:a93858b247b9, 2016-04-15 (annotated)
- Committer:
- stefan1691
- Date:
- Fri Apr 15 18:14:33 2016 +0000
- Revision:
- 14:a93858b247b9
- Parent:
- 1:2e29a33cd918
restsql mit HTTP GET
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| marcel1691 | 1:2e29a33cd918 | 1 | #ifndef HTTPFILE_H |
| marcel1691 | 1:2e29a33cd918 | 2 | #define HTTPFILE_H |
| marcel1691 | 1:2e29a33cd918 | 3 | #if 1 |
| marcel1691 | 1:2e29a33cd918 | 4 | #include <mbed.h> |
| marcel1691 | 1:2e29a33cd918 | 5 | #include "../IHTTPData.h" |
| marcel1691 | 1:2e29a33cd918 | 6 | |
| marcel1691 | 1:2e29a33cd918 | 7 | |
| marcel1691 | 1:2e29a33cd918 | 8 | class HTTPFile : public IHTTPDataIn { |
| marcel1691 | 1:2e29a33cd918 | 9 | |
| marcel1691 | 1:2e29a33cd918 | 10 | public: |
| marcel1691 | 1:2e29a33cd918 | 11 | HTTPFile(char* filename); |
| marcel1691 | 1:2e29a33cd918 | 12 | |
| marcel1691 | 1:2e29a33cd918 | 13 | /** Closes the file, should be called once the http connection is closed. |
| marcel1691 | 1:2e29a33cd918 | 14 | */ |
| marcel1691 | 1:2e29a33cd918 | 15 | void close(); |
| marcel1691 | 1:2e29a33cd918 | 16 | |
| marcel1691 | 1:2e29a33cd918 | 17 | protected: |
| marcel1691 | 1:2e29a33cd918 | 18 | |
| marcel1691 | 1:2e29a33cd918 | 19 | friend class HTTPClient; |
| marcel1691 | 1:2e29a33cd918 | 20 | |
| marcel1691 | 1:2e29a33cd918 | 21 | /** Reset stream to its beginning |
| marcel1691 | 1:2e29a33cd918 | 22 | * Called by the HTTPClient on each new request |
| marcel1691 | 1:2e29a33cd918 | 23 | */ |
| marcel1691 | 1:2e29a33cd918 | 24 | virtual void writeReset(); |
| marcel1691 | 1:2e29a33cd918 | 25 | |
| marcel1691 | 1:2e29a33cd918 | 26 | /** Write a piece of data transmitted by the server |
| marcel1691 | 1:2e29a33cd918 | 27 | * @param[in] buf Pointer to the buffer from which to copy the data |
| marcel1691 | 1:2e29a33cd918 | 28 | * @param[in] len Length of the buffer |
| marcel1691 | 1:2e29a33cd918 | 29 | * @returns number of bytes written. |
| marcel1691 | 1:2e29a33cd918 | 30 | */ |
| marcel1691 | 1:2e29a33cd918 | 31 | virtual int write(const char* buf, size_t len); |
| marcel1691 | 1:2e29a33cd918 | 32 | |
| marcel1691 | 1:2e29a33cd918 | 33 | /** Set MIME type |
| marcel1691 | 1:2e29a33cd918 | 34 | * @param[in] type Internet media type from Content-Type header |
| marcel1691 | 1:2e29a33cd918 | 35 | */ |
| marcel1691 | 1:2e29a33cd918 | 36 | virtual void setDataType(const char* type); |
| marcel1691 | 1:2e29a33cd918 | 37 | |
| marcel1691 | 1:2e29a33cd918 | 38 | /** Determine whether the data is chunked |
| marcel1691 | 1:2e29a33cd918 | 39 | * Recovered from Transfer-Encoding header |
| marcel1691 | 1:2e29a33cd918 | 40 | * @param[in] chunked indicates the transfer is chunked. |
| marcel1691 | 1:2e29a33cd918 | 41 | */ |
| marcel1691 | 1:2e29a33cd918 | 42 | virtual void setIsChunked(bool chunked); |
| marcel1691 | 1:2e29a33cd918 | 43 | |
| marcel1691 | 1:2e29a33cd918 | 44 | /** If the data is not chunked, set its size |
| marcel1691 | 1:2e29a33cd918 | 45 | * From Content-Length header |
| marcel1691 | 1:2e29a33cd918 | 46 | * @param[in] len defines the size of the non-chunked transfer. |
| marcel1691 | 1:2e29a33cd918 | 47 | */ |
| marcel1691 | 1:2e29a33cd918 | 48 | virtual void setDataLen(size_t len); |
| marcel1691 | 1:2e29a33cd918 | 49 | private: |
| marcel1691 | 1:2e29a33cd918 | 50 | FILE *file; |
| marcel1691 | 1:2e29a33cd918 | 51 | size_t m_len; |
| marcel1691 | 1:2e29a33cd918 | 52 | bool m_chunked; |
| marcel1691 | 1:2e29a33cd918 | 53 | }; |
| marcel1691 | 1:2e29a33cd918 | 54 | #endif |
| marcel1691 | 1:2e29a33cd918 | 55 | #endif // HTTPFILE_H |
