HTTP Client data container for form(multipart/form-data)
Dependencies: mbed EthernetInterface HTTPClient mbed-rtos
HTTPPoster.h
- Committer:
- va009039
- Date:
- 2012-05-31
- Revision:
- 0:fcd577a3925b
- Child:
- 1:77c616a1ab54
File content as of revision 0:fcd577a3925b:
#ifndef HTTP_POSTER_H #define HTTP_POSTER_H #include "mbed.h" #include "HTTPData.h" #include <vector> /** HTTPPoster HTTP Client data container for form(multipart/form-data) * *@code *HTTPClient client; *HTTPPoster data; *data.addFile("image", "/local/image.jpg"); *data.add("title", "hello"); *string url = "http://va009039.appspot.com/mbed/upload/"; *HTTPResult r = client.post(url.c_str(), data, NULL); *printf("result:%d HTTPResponseCode: %d\n", r, client.getHTTPResponseCode()); *@endcode */ struct stpost { bool file; string head; string value; int length; }; ///HTTPPoster HTTP Client data container for form(multipart/form-data) class HTTPPoster : public HTTPData { public: ///Instantiates the object. HTTPPoster(); ///put file bool addFile(const char* name, const char* path); ///put param bool add(const char* name, const char* value); virtual ~HTTPPoster(); virtual void clear() {}; protected: virtual string getDataType(); virtual int getDataLen(); virtual int read(char* buf, int len); virtual int write(const char* buf, int len) { return 0;} virtual void setDataType(const string& type) {} virtual bool getIsChunked() {return false;} virtual void setIsChunked(bool chunked) {} virtual void setDataLen(int len) {} private: int m_seq; int m_cur; int m_pos; vector <stpost> m_post_data; FILE* m_fp; int m_len; int m_send_len; string m_buf; string m_ContentType; char* m_boundary; }; #endif