It is the new miniTLS program which build the connect with the website httpbin.org
Fork of MiniTLS-HTTPSClient by
data/HTTPMap.h@0:62a4a8ec4ab5, 2014-06-10 (annotated)
- Committer:
- MiniTLS
- Date:
- Tue Jun 10 14:23:22 2014 +0000
- Revision:
- 0:62a4a8ec4ab5
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MiniTLS | 0:62a4a8ec4ab5 | 1 | /* HTTPMap.h */ |
MiniTLS | 0:62a4a8ec4ab5 | 2 | /* Copyright (C) 2012 mbed.org, MIT License |
MiniTLS | 0:62a4a8ec4ab5 | 3 | * |
MiniTLS | 0:62a4a8ec4ab5 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
MiniTLS | 0:62a4a8ec4ab5 | 5 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
MiniTLS | 0:62a4a8ec4ab5 | 6 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
MiniTLS | 0:62a4a8ec4ab5 | 7 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
MiniTLS | 0:62a4a8ec4ab5 | 8 | * furnished to do so, subject to the following conditions: |
MiniTLS | 0:62a4a8ec4ab5 | 9 | * |
MiniTLS | 0:62a4a8ec4ab5 | 10 | * The above copyright notice and this permission notice shall be included in all copies or |
MiniTLS | 0:62a4a8ec4ab5 | 11 | * substantial portions of the Software. |
MiniTLS | 0:62a4a8ec4ab5 | 12 | * |
MiniTLS | 0:62a4a8ec4ab5 | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
MiniTLS | 0:62a4a8ec4ab5 | 14 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
MiniTLS | 0:62a4a8ec4ab5 | 15 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
MiniTLS | 0:62a4a8ec4ab5 | 16 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
MiniTLS | 0:62a4a8ec4ab5 | 17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
MiniTLS | 0:62a4a8ec4ab5 | 18 | */ |
MiniTLS | 0:62a4a8ec4ab5 | 19 | |
MiniTLS | 0:62a4a8ec4ab5 | 20 | |
MiniTLS | 0:62a4a8ec4ab5 | 21 | #ifndef HTTPMAP_H_ |
MiniTLS | 0:62a4a8ec4ab5 | 22 | #define HTTPMAP_H_ |
MiniTLS | 0:62a4a8ec4ab5 | 23 | |
MiniTLS | 0:62a4a8ec4ab5 | 24 | #include "../IHTTPData.h" |
MiniTLS | 0:62a4a8ec4ab5 | 25 | |
MiniTLS | 0:62a4a8ec4ab5 | 26 | #define HTTPMAP_TABLE_SIZE 32 |
MiniTLS | 0:62a4a8ec4ab5 | 27 | |
MiniTLS | 0:62a4a8ec4ab5 | 28 | /** Map of key/value pairs |
MiniTLS | 0:62a4a8ec4ab5 | 29 | * Used to transmit POST data using the application/x-www-form-urlencoded encoding |
MiniTLS | 0:62a4a8ec4ab5 | 30 | */ |
MiniTLS | 0:62a4a8ec4ab5 | 31 | class HTTPMap: public IHTTPDataOut |
MiniTLS | 0:62a4a8ec4ab5 | 32 | { |
MiniTLS | 0:62a4a8ec4ab5 | 33 | public: |
MiniTLS | 0:62a4a8ec4ab5 | 34 | /** |
MiniTLS | 0:62a4a8ec4ab5 | 35 | Instantiates HTTPMap |
MiniTLS | 0:62a4a8ec4ab5 | 36 | It supports at most 32 key/values pairs |
MiniTLS | 0:62a4a8ec4ab5 | 37 | */ |
MiniTLS | 0:62a4a8ec4ab5 | 38 | HTTPMap(); |
MiniTLS | 0:62a4a8ec4ab5 | 39 | |
MiniTLS | 0:62a4a8ec4ab5 | 40 | /** Put Key/Value pair |
MiniTLS | 0:62a4a8ec4ab5 | 41 | The references to the parameters must remain valid as long as the clear() function is not called |
MiniTLS | 0:62a4a8ec4ab5 | 42 | @param key The key to use |
MiniTLS | 0:62a4a8ec4ab5 | 43 | @param value The corresponding value |
MiniTLS | 0:62a4a8ec4ab5 | 44 | */ |
MiniTLS | 0:62a4a8ec4ab5 | 45 | void put(const char* key, const char* value); |
MiniTLS | 0:62a4a8ec4ab5 | 46 | |
MiniTLS | 0:62a4a8ec4ab5 | 47 | /** Clear table |
MiniTLS | 0:62a4a8ec4ab5 | 48 | */ |
MiniTLS | 0:62a4a8ec4ab5 | 49 | void clear(); |
MiniTLS | 0:62a4a8ec4ab5 | 50 | |
MiniTLS | 0:62a4a8ec4ab5 | 51 | protected: |
MiniTLS | 0:62a4a8ec4ab5 | 52 | //IHTTPDataIn |
MiniTLS | 0:62a4a8ec4ab5 | 53 | virtual void readReset(); |
MiniTLS | 0:62a4a8ec4ab5 | 54 | |
MiniTLS | 0:62a4a8ec4ab5 | 55 | virtual int read(char* buf, size_t len, size_t* pReadLen); |
MiniTLS | 0:62a4a8ec4ab5 | 56 | |
MiniTLS | 0:62a4a8ec4ab5 | 57 | virtual int getDataType(char* type, size_t maxTypeLen); //Internet media type for Content-Type header |
MiniTLS | 0:62a4a8ec4ab5 | 58 | |
MiniTLS | 0:62a4a8ec4ab5 | 59 | virtual bool getIsChunked(); //For Transfer-Encoding header |
MiniTLS | 0:62a4a8ec4ab5 | 60 | |
MiniTLS | 0:62a4a8ec4ab5 | 61 | virtual size_t getDataLen(); //For Content-Length header |
MiniTLS | 0:62a4a8ec4ab5 | 62 | |
MiniTLS | 0:62a4a8ec4ab5 | 63 | private: |
MiniTLS | 0:62a4a8ec4ab5 | 64 | const char* m_keys[HTTPMAP_TABLE_SIZE]; |
MiniTLS | 0:62a4a8ec4ab5 | 65 | const char* m_values[HTTPMAP_TABLE_SIZE]; |
MiniTLS | 0:62a4a8ec4ab5 | 66 | |
MiniTLS | 0:62a4a8ec4ab5 | 67 | size_t m_pos; |
MiniTLS | 0:62a4a8ec4ab5 | 68 | size_t m_count; |
MiniTLS | 0:62a4a8ec4ab5 | 69 | }; |
MiniTLS | 0:62a4a8ec4ab5 | 70 | |
MiniTLS | 0:62a4a8ec4ab5 | 71 | #endif /* HTTPMAP_H_ */ |