Committer:
donatien
Date:
Fri Jul 06 10:22:15 2012 +0000
Revision:
0:7aca7353eebf
Fixed parseURL issue for port parsing

Who changed what in which revision?

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