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.
Fork of HTTPClient by
IHTTPData.h
00001 /* IHTTPData.h */ 00002 /* Copyright (C) 2012 mbed.org, MIT License 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00005 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00006 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00007 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00008 * furnished to do so, subject to the following conditions: 00009 * 00010 * The above copyright notice and this permission notice shall be included in all copies or 00011 * substantial portions of the Software. 00012 * 00013 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00014 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00015 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00016 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00018 */ 00019 00020 #ifndef IHTTPDATA_H 00021 #define IHTTPDATA_H 00022 00023 #include <cstring> 00024 00025 using std::size_t; 00026 00027 ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...) 00028 class IHTTPDataOut 00029 { 00030 protected: 00031 friend class HTTPClient; 00032 00033 /** Reset stream to its beginning 00034 * Called by the HTTPClient on each new request 00035 */ 00036 virtual void readReset() = 0; 00037 00038 /** Read a piece of data to be transmitted 00039 * @param buf Pointer to the buffer on which to copy the data 00040 * @param len Length of the buffer 00041 * @param pReadLen Pointer to the variable on which the actual copied data length will be stored 00042 */ 00043 virtual int read(char* buf, size_t len, size_t* pReadLen) = 0; 00044 00045 /** Get MIME type 00046 * @param type Internet media type from Content-Type header 00047 */ 00048 virtual int getDataType(char* type, size_t maxTypeLen) = 0; //Internet media type for Content-Type header 00049 00050 /** Determine whether the HTTP client should chunk the data 00051 * Used for Transfer-Encoding header 00052 */ 00053 virtual bool getIsChunked() = 0; 00054 00055 /** If the data is not chunked, get its size 00056 * Used for Content-Length header 00057 */ 00058 virtual size_t getDataLen() = 0; 00059 00060 }; 00061 00062 ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...) 00063 class IHTTPDataIn 00064 { 00065 protected: 00066 friend class HTTPClient; 00067 00068 /** Reset stream to its beginning 00069 * Called by the HTTPClient on each new request 00070 */ 00071 virtual void writeReset() = 0; 00072 00073 /** Write a piece of data transmitted by the server 00074 * @param buf Pointer to the buffer from which to copy the data 00075 * @param len Length of the buffer 00076 */ 00077 virtual int write(const char* buf, size_t len) = 0; 00078 00079 /** Set MIME type 00080 * @param type Internet media type from Content-Type header 00081 */ 00082 virtual void setDataType(const char* type) = 0; 00083 00084 /** Determine whether the data is chunked 00085 * Recovered from Transfer-Encoding header 00086 */ 00087 virtual void setIsChunked(bool chunked) = 0; 00088 00089 /** If the data is not chunked, set its size 00090 * From Content-Length header 00091 */ 00092 virtual void setDataLen(size_t len) = 0; 00093 00094 }; 00095 00096 #endif
Generated on Wed Jul 13 2022 02:53:58 by
1.7.2
