]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/tests/net/cellular/http/common/HTTPClient/data/HTTPMap.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / tests / net / cellular / http / common / HTTPClient / data / HTTPMap.h
1 /* HTTPMap.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 HTTPMAP_H_
22 #define HTTPMAP_H_
23
24 #include "../IHTTPData.h"
25
26 #define HTTPMAP_TABLE_SIZE 32
27
28 /** Map of key/value pairs
29 * Used to transmit POST data using the application/x-www-form-urlencoded encoding
30 */
31 class HTTPMap: public IHTTPDataOut
32 {
33 public:
34 /**
35 Instantiates HTTPMap
36 It supports at most 32 key/values pairs
37 */
38 HTTPMap();
39
40 /** Put Key/Value pair
41 The references to the parameters must remain valid as long as the clear() function is not called
42 @param key The key to use
43 @param value The corresponding value
44 */
45 void put(const char* key, const char* value);
46
47 /** Clear table
48 */
49 void clear();
50
51 protected:
52 //IHTTPDataIn
53 virtual void readReset();
54
55 virtual int read(char* buf, size_t len, size_t* pReadLen);
56
57 virtual int getDataType(char* type, size_t maxTypeLen); //Internet media type for Content-Type header
58
59 virtual bool getIsChunked(); //For Transfer-Encoding header
60
61 virtual size_t getDataLen(); //For Content-Length header
62
63 private:
64 const char* m_keys[HTTPMAP_TABLE_SIZE];
65 const char* m_values[HTTPMAP_TABLE_SIZE];
66
67 size_t m_pos;
68 size_t m_count;
69 };
70
71 #endif /* HTTPMAP_H_ */
Imprint / Impressum