Fixed custom headers and Basic authorization, added support for redirection, functional file download interface can be used for SW updates and more.
Dependents: Sample_HTTPClient Sample_HTTPClient LWM2M_NanoService_Ethernet LWM2M_NanoService_Ethernet ... more
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[out] buf Pointer to the buffer on which to copy the data 00040 * @param[in] len Length of the buffer 00041 * @param[out] 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[out] type Internet media type from Content-Type header 00047 * @param[in] maxTypeLen is the size of the type buffer to write to 00048 */ 00049 virtual int getDataType(char* type, size_t maxTypeLen) = 0; //Internet media type for Content-Type header 00050 00051 /** Determine whether the HTTP client should chunk the data 00052 * Used for Transfer-Encoding header 00053 */ 00054 virtual bool getIsChunked() = 0; 00055 00056 /** If the data is not chunked, get its size 00057 * Used for Content-Length header 00058 */ 00059 virtual size_t getDataLen() = 0; 00060 00061 }; 00062 00063 ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...) 00064 class IHTTPDataIn 00065 { 00066 protected: 00067 friend class HTTPClient; 00068 00069 /** Reset stream to its beginning 00070 * Called by the HTTPClient on each new request 00071 */ 00072 virtual void writeReset() = 0; 00073 00074 /** Write a piece of data transmitted by the server 00075 * @param buf Pointer to the buffer from which to copy the data 00076 * @param len Length of the buffer 00077 */ 00078 virtual int write(const char* buf, size_t len) = 0; 00079 00080 /** Set MIME type 00081 * @param type Internet media type from Content-Type header 00082 */ 00083 virtual void setDataType(const char* type) = 0; 00084 00085 /** Determine whether the data is chunked 00086 * Recovered from Transfer-Encoding header 00087 */ 00088 virtual void setIsChunked(bool chunked) = 0; 00089 00090 /** If the data is not chunked, set its size 00091 * From Content-Length header 00092 */ 00093 virtual void setDataLen(size_t len) = 0; 00094 00095 }; 00096 00097 #endif
Generated on Tue Jul 12 2022 17:30:36 by
![doxygen](doxygen.png)