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 mbed-os 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 /** Read a piece of data to be transmitted 00034 * @param buf Pointer to the buffer on which to copy the data 00035 * @param len Length of the buffer 00036 * @param pReadLen Pointer to the variable on which the actual copied data length will be stored 00037 */ 00038 virtual int read(char* buf, size_t len, size_t* pReadLen) = 0; 00039 00040 /** Get MIME type 00041 * @param type Internet media type from Content-Type header 00042 */ 00043 virtual int getDataType(char* type, size_t maxTypeLen) = 0; //Internet media type for Content-Type header 00044 00045 /** Determine whether the HTTP client should chunk the data 00046 * Used for Transfer-Encoding header 00047 */ 00048 virtual bool getIsChunked() = 0; 00049 00050 /** If the data is not chunked, get its size 00051 * Used for Content-Length header 00052 */ 00053 virtual size_t getDataLen() = 0; 00054 00055 }; 00056 00057 ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...) 00058 class IHTTPDataIn 00059 { 00060 protected: 00061 friend class HTTPClient; 00062 00063 /** Write a piece of data transmitted by the server 00064 * @param buf Pointer to the buffer from which to copy the data 00065 * @param len Length of the buffer 00066 */ 00067 virtual int write(const char* buf, size_t len) = 0; 00068 00069 /** Set MIME type 00070 * @param type Internet media type from Content-Type header 00071 */ 00072 virtual void setDataType(const char* type) = 0; 00073 00074 /** Determine whether the data is chunked 00075 * Recovered from Transfer-Encoding header 00076 */ 00077 virtual void setIsChunked(bool chunked) = 0; 00078 00079 /** If the data is not chunked, set its size 00080 * From Content-Length header 00081 */ 00082 virtual void setDataLen(size_t len) = 0; 00083 00084 }; 00085 00086 #endif
Generated on Tue Jul 12 2022 13:15:51 by
