Fork of wolfSSL's HTTPClient fork. Fork!
Dependents: exosite_http_example exosite_http_example
Fork of HTTPClient by
Diff: data/HTTPMap.h
- Revision:
- 33:bdd333d3939c
- Parent:
- 16:1f743885e7de
--- a/data/HTTPMap.h Fri Dec 05 07:03:47 2014 +0000 +++ b/data/HTTPMap.h Tue Jan 20 14:13:54 2015 -0600 @@ -28,7 +28,7 @@ /** Map of key/value pairs * Used to transmit POST data using the application/x-www-form-urlencoded encoding */ -class HTTPMap: public IHTTPDataOut +class HTTPMap: public IHTTPDataIn, public IHTTPDataOut { public: /** @@ -37,6 +37,12 @@ */ HTTPMap(); + /** Create an HTTPMap instance for input + * @param str Buffer to store the incoming string + * @param size Size of the buffer + */ + HTTPMap(char* buf, size_t size); + /** Put Key/Value pair The references to the parameters must remain valid as long as the clear() function is not called @param key The key to use @@ -44,12 +50,28 @@ */ void put(const char* key, const char* value); + /** Pop one Key/Value pair + The returned refrences remain valid as long as the original buffer is not modified + @param key The key + @param value The corresponding value + */ + bool pop(char*& key, char*& value); + + /** Get Value specified in Key + The value is copied into the provided buffer + @param key The key of the value to get + @param val_buf The output buffer into which the value will be copied + @param max The size of the buffer + @param len The number of bytes copied into the output buffer + */ + bool get(const char* key, char* val_buf, const size_t max); + /** Clear table */ void clear(); protected: - //IHTTPDataIn + //IHTTPDataOut virtual void readReset(); virtual int read(char* buf, size_t len, size_t* pReadLen); @@ -60,12 +82,28 @@ virtual size_t getDataLen(); //For Content-Length header + //IHTTPDataIn + virtual void writeReset(); + + virtual int write(const char* buf, size_t len); + + virtual void setDataType(const char* type); //Internet media type from Content-Type header + + virtual void setIsChunked(bool chunked); //From Transfer-Encoding header + + virtual void setDataLen(size_t len); //From Content-Length header, or if the transfer is chunked, next chunk length + private: const char* m_keys[HTTPMAP_TABLE_SIZE]; const char* m_values[HTTPMAP_TABLE_SIZE]; + + char* m_str; + size_t m_size; size_t m_pos; size_t m_count; + + size_t m_read_pos; }; #endif /* HTTPMAP_H_ */