Fork HTTPClient and Modfiy code for mbed 6.0
Dependents: mbed-demo-http-get-json
IHTTPData.h@0:2ccb9960a044, 2012-04-26 (annotated)
- Committer:
- donatien
- Date:
- Thu Apr 26 13:04:56 2012 +0000
- Revision:
- 0:2ccb9960a044
- Child:
- 10:e1351de84c16
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 0:2ccb9960a044 | 1 | /* IHTTPData.h */ |
donatien | 0:2ccb9960a044 | 2 | /* |
donatien | 0:2ccb9960a044 | 3 | Copyright (C) 2012 ARM Limited. |
donatien | 0:2ccb9960a044 | 4 | |
donatien | 0:2ccb9960a044 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of |
donatien | 0:2ccb9960a044 | 6 | this software and associated documentation files (the "Software"), to deal in |
donatien | 0:2ccb9960a044 | 7 | the Software without restriction, including without limitation the rights to |
donatien | 0:2ccb9960a044 | 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
donatien | 0:2ccb9960a044 | 9 | of the Software, and to permit persons to whom the Software is furnished to do |
donatien | 0:2ccb9960a044 | 10 | so, subject to the following conditions: |
donatien | 0:2ccb9960a044 | 11 | |
donatien | 0:2ccb9960a044 | 12 | The above copyright notice and this permission notice shall be included in all |
donatien | 0:2ccb9960a044 | 13 | copies or substantial portions of the Software. |
donatien | 0:2ccb9960a044 | 14 | |
donatien | 0:2ccb9960a044 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
donatien | 0:2ccb9960a044 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
donatien | 0:2ccb9960a044 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
donatien | 0:2ccb9960a044 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
donatien | 0:2ccb9960a044 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
donatien | 0:2ccb9960a044 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
donatien | 0:2ccb9960a044 | 21 | SOFTWARE. |
donatien | 0:2ccb9960a044 | 22 | */ |
donatien | 0:2ccb9960a044 | 23 | |
donatien | 0:2ccb9960a044 | 24 | #ifndef IHTTPDATA_H |
donatien | 0:2ccb9960a044 | 25 | #define IHTTPDATA_H |
donatien | 0:2ccb9960a044 | 26 | |
donatien | 0:2ccb9960a044 | 27 | ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...) |
donatien | 0:2ccb9960a044 | 28 | class IHTTPDataOut |
donatien | 0:2ccb9960a044 | 29 | { |
donatien | 0:2ccb9960a044 | 30 | protected: |
donatien | 0:2ccb9960a044 | 31 | friend class HTTPClient; |
donatien | 0:2ccb9960a044 | 32 | |
donatien | 0:2ccb9960a044 | 33 | /** Read a piece of data to be transmitted |
donatien | 0:2ccb9960a044 | 34 | * @param buf Pointer to the buffer on which to copy the data |
donatien | 0:2ccb9960a044 | 35 | * @param len Length of the buffer |
donatien | 0:2ccb9960a044 | 36 | * @param pReadLen Pointer to the variable on which the actual copied data length will be stored |
donatien | 0:2ccb9960a044 | 37 | */ |
donatien | 0:2ccb9960a044 | 38 | virtual int read(char* buf, size_t len, size_t* pReadLen) = 0; |
donatien | 0:2ccb9960a044 | 39 | |
donatien | 0:2ccb9960a044 | 40 | /** Get MIME type |
donatien | 0:2ccb9960a044 | 41 | * @param type Internet media type from Content-Type header |
donatien | 0:2ccb9960a044 | 42 | */ |
donatien | 0:2ccb9960a044 | 43 | virtual int getDataType(char* type, size_t maxTypeLen) = 0; //Internet media type for Content-Type header |
donatien | 0:2ccb9960a044 | 44 | |
donatien | 0:2ccb9960a044 | 45 | /** Determine whether the HTTP client should chunk the data |
donatien | 0:2ccb9960a044 | 46 | * Used for Transfer-Encoding header |
donatien | 0:2ccb9960a044 | 47 | */ |
donatien | 0:2ccb9960a044 | 48 | virtual bool getIsChunked() = 0; |
donatien | 0:2ccb9960a044 | 49 | |
donatien | 0:2ccb9960a044 | 50 | /** If the data is not chunked, get its size |
donatien | 0:2ccb9960a044 | 51 | * Used for Content-Length header |
donatien | 0:2ccb9960a044 | 52 | */ |
donatien | 0:2ccb9960a044 | 53 | virtual size_t getDataLen() = 0; |
donatien | 0:2ccb9960a044 | 54 | |
donatien | 0:2ccb9960a044 | 55 | }; |
donatien | 0:2ccb9960a044 | 56 | |
donatien | 0:2ccb9960a044 | 57 | ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...) |
donatien | 0:2ccb9960a044 | 58 | class IHTTPDataIn |
donatien | 0:2ccb9960a044 | 59 | { |
donatien | 0:2ccb9960a044 | 60 | protected: |
donatien | 0:2ccb9960a044 | 61 | friend class HTTPClient; |
donatien | 0:2ccb9960a044 | 62 | |
donatien | 0:2ccb9960a044 | 63 | /** Write a piece of data transmitted by the server |
donatien | 0:2ccb9960a044 | 64 | * @param buf Pointer to the buffer from which to copy the data |
donatien | 0:2ccb9960a044 | 65 | * @param len Length of the buffer |
donatien | 0:2ccb9960a044 | 66 | */ |
donatien | 0:2ccb9960a044 | 67 | virtual int write(const char* buf, size_t len) = 0; |
donatien | 0:2ccb9960a044 | 68 | |
donatien | 0:2ccb9960a044 | 69 | /** Set MIME type |
donatien | 0:2ccb9960a044 | 70 | * @param type Internet media type from Content-Type header |
donatien | 0:2ccb9960a044 | 71 | */ |
donatien | 0:2ccb9960a044 | 72 | virtual void setDataType(const char* type) = 0; |
donatien | 0:2ccb9960a044 | 73 | |
donatien | 0:2ccb9960a044 | 74 | /** Determine whether the data is chunked |
donatien | 0:2ccb9960a044 | 75 | * Recovered from Transfer-Encoding header |
donatien | 0:2ccb9960a044 | 76 | */ |
donatien | 0:2ccb9960a044 | 77 | virtual void setIsChunked(bool chunked) = 0; |
donatien | 0:2ccb9960a044 | 78 | |
donatien | 0:2ccb9960a044 | 79 | /** If the data is not chunked, set its size |
donatien | 0:2ccb9960a044 | 80 | * From Content-Length header |
donatien | 0:2ccb9960a044 | 81 | */ |
donatien | 0:2ccb9960a044 | 82 | virtual void setDataLen(size_t len) = 0; |
donatien | 0:2ccb9960a044 | 83 | |
donatien | 0:2ccb9960a044 | 84 | }; |
donatien | 0:2ccb9960a044 | 85 | |
donatien | 0:2ccb9960a044 | 86 | #endif |