]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/cellular/http/common/HTTPClient/data/HTTPText.h
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / tests / net / cellular / http / common / HTTPClient / data / HTTPText.h
1 /* HTTPText.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
21 #ifndef HTTPTEXT_H_
22 #define HTTPTEXT_H_
23
24 #include "../IHTTPData.h"
25
26 /** A data endpoint to store text
27 */
28 class HTTPText : public IHTTPDataIn, public IHTTPDataOut
29 {
30 public:
31 /** Create an HTTPText instance for output
32 * @param str String to be transmitted
33 */
34 HTTPText(char* str);
35
36 /** Create an HTTPText instance for input
37 * @param str Buffer to store the incoming string
38 * @param size Size of the buffer
39 */
40 HTTPText(char* str, size_t size);
41
42 protected:
43 //IHTTPDataIn
44 virtual void readReset();
45
46 virtual int read(char* buf, size_t len, size_t* pReadLen);
47
48 virtual int getDataType(char* type, size_t maxTypeLen); //Internet media type for Content-Type header
49
50 virtual bool getIsChunked(); //For Transfer-Encoding header
51
52 virtual size_t getDataLen(); //For Content-Length header
53
54 //IHTTPDataOut
55 virtual void writeReset();
56
57 virtual int write(const char* buf, size_t len);
58
59 virtual void setDataType(const char* type); //Internet media type from Content-Type header
60
61 virtual void setIsChunked(bool chunked); //From Transfer-Encoding header
62
63 virtual void setDataLen(size_t len); //From Content-Length header, or if the transfer is chunked, next chunk length
64
65 private:
66 char* m_str;
67 size_t m_size;
68
69 size_t m_pos;
70 };
71
72 #endif /* HTTPTEXT_H_ */
Imprint / Impressum