00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef MS_HTTP_CLIENT_MIME_HPP
00018 #define MS_HTTP_CLIENT_MIME_HPP
00019
00020
00021 #include <string>
00022 #include <vector>
00023
00024 namespace matrix_science
00025 {
00031
00032 class MS_MASCOTRESFILE_API ms_http_client_mime_item
00033 {
00034 public:
00035 ms_http_client_mime_item();
00036 ms_http_client_mime_item(const std::string & name, const std::string & value);
00037 ms_http_client_mime_item(const std::string & name, const std::string & value, const std::string & filename, const std::string & contentType);
00038
00039 std::string name() const;
00040 std::string value() const;
00041 bool hasFilename() const;
00042 std::string filename() const;
00043 std::string contentType() const;
00044
00045 void setName(const std::string & name);
00046 void setValue(const std::string & value);
00047 void setValueWithFilename(const std::string & value, const std::string & filename, const std::string & contentType);
00048
00049 private:
00050 std::string name_;
00051 std::string value_;
00052 bool hasFilename_;
00053 std::string filename_;
00054 std::string contentType_;
00055 };
00056
00058
00066 class MS_MASCOTRESFILE_API ms_http_client_mime
00067 {
00068 public:
00069 enum ContentType {
00070 CT_MIXED,
00071 CT_FORMDATA
00072 };
00073
00074 enum Continuation {
00075 CONTENT_CONTINUES,
00076 CONTENT_TERMINATES
00077 };
00078
00080 static std::string formatHeader(
00081 const std::string & boundary,
00082 ContentType contentType);
00083
00085 virtual ~ms_http_client_mime();
00086
00088 void append(const std::string & name, const std::string & value);
00089
00091 void appendFile(const std::string & name, const std::string & filename, const std::string & contentType, const std::string & prefixData = "");
00092
00093
00095 int getCount() const;
00096 int count() const { return getCount(); }
00097
00098
00100 std::string getName(int oneBasedIndex) const;
00101 std::string name(int oneBasedIndex) const { return getName(oneBasedIndex); }
00102
00104 std::string getValue(int oneBasedIndex) const;
00105 std::string value(int oneBasedIndex) const { return getValue(oneBasedIndex); }
00106
00108 bool hasFilename(int oneBasedIndex) const;
00109
00111 std::string getFilename(int oneBasedIndex) const;
00112 std::string filename(int oneBasedIndex) const { return getFilename(oneBasedIndex); }
00113
00114
00116 void setValue(int oneBasedIndex, const std::string & value);
00117
00119 void setValueWithFilename(int oneBasedIndex, const std::string & value, const std::string & filename, const std::string & contentType);
00120
00121
00123 void erase(int oneBasedIndex);
00124
00126 std::string format(
00127 const std::string & boundary,
00128 matrix_science::ms_http_client_mime::Continuation continuation) const;
00129
00130 private:
00131 std::vector<ms_http_client_mime_item> items_;
00132 };
00133
00135
00136 }
00137
00138 #endif // MS_HTTP_CLIENT_MIME_HPP
00139
00140