]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/tests/net/cellular/http/common/HTTPClient/IHTTPData.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / tests / net / cellular / http / common / HTTPClient / IHTTPData.h
1 /* IHTTPData.h */
2 /* Copyright (C) 2012 mbed.org, MIT License
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in all copies or
11 * substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 */
19
20 #ifndef IHTTPDATA_H
21 #define IHTTPDATA_H
22
23 #include <cstring>
24
25 using std::size_t;
26
27 ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...)
28 class IHTTPDataOut
29 {
30 protected:
31 friend class HTTPClient;
32
33 /** Reset stream to its beginning
34 * Called by the HTTPClient on each new request
35 */
36 virtual void readReset() = 0;
37
38 /** Read a piece of data to be transmitted
39 * @param buf Pointer to the buffer on which to copy the data
40 * @param len Length of the buffer
41 * @param pReadLen Pointer to the variable on which the actual copied data length will be stored
42 */
43 virtual int read(char* buf, size_t len, size_t* pReadLen) = 0;
44
45 /** Get MIME type
46 * @param type Internet media type from Content-Type header
47 */
48 virtual int getDataType(char* type, size_t maxTypeLen) = 0; //Internet media type for Content-Type header
49
50 /** Determine whether the HTTP client should chunk the data
51 * Used for Transfer-Encoding header
52 */
53 virtual bool getIsChunked() = 0;
54
55 /** If the data is not chunked, get its size
56 * Used for Content-Length header
57 */
58 virtual size_t getDataLen() = 0;
59
60 };
61
62 ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...)
63 class IHTTPDataIn
64 {
65 protected:
66 friend class HTTPClient;
67
68 /** Reset stream to its beginning
69 * Called by the HTTPClient on each new request
70 */
71 virtual void writeReset() = 0;
72
73 /** Write a piece of data transmitted by the server
74 * @param buf Pointer to the buffer from which to copy the data
75 * @param len Length of the buffer
76 */
77 virtual int write(const char* buf, size_t len) = 0;
78
79 /** Set MIME type
80 * @param type Internet media type from Content-Type header
81 */
82 virtual void setDataType(const char* type) = 0;
83
84 /** Determine whether the data is chunked
85 * Recovered from Transfer-Encoding header
86 */
87 virtual void setIsChunked(bool chunked) = 0;
88
89 /** If the data is not chunked, set its size
90 * From Content-Length header
91 */
92 virtual void setDataLen(size_t len) = 0;
93
94 };
95
96 #endif
Imprint / Impressum