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