00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _HTTPRESPONSEHEADER_H_
00023 #define _HTTPRESPONSEHEADER_H_ 1
00024
00025 #ifdef __GNUG__
00026 # pragma interface
00027 #endif
00028
00036 #include <string>
00037 #include <vector>
00038
00039 #include "cgicc/MStreamable.h"
00040 #include "cgicc/HTTPCookie.h"
00041
00042 namespace cgicc {
00043
00044
00045
00046
00071 class CGICC_API HTTPResponseHeader : public MStreamable
00072 {
00073 public:
00074
00077
00084 HTTPResponseHeader(const std::string& http_version,
00085 int status_code,
00086 const std::string& reason_phrase);
00087
00092 virtual ~HTTPResponseHeader();
00094
00095
00096
00099
00106 HTTPResponseHeader&
00107 addHeader(const std::string& header);
00108
00116 HTTPResponseHeader&
00117 addHeader(const std::string& name,
00118 const std::string& value);
00119
00125 inline const std::vector<std::string>&
00126 getHeaders() const
00127 { return fHeaders; }
00129
00132
00137 HTTPResponseHeader&
00138 setCookie(const HTTPCookie& cookie);
00139
00144 inline const std::vector<HTTPCookie>&
00145 getCookies() const
00146 { return fCookies; }
00148
00149
00150
00155
00162 inline const std::string&
00163 getHTTPVersion() const
00164 { return fHTTPVersion; }
00165
00172 inline int
00173 getStatusCode() const
00174 { return fStatusCode; }
00175
00182 inline std::string
00183 getReasonPhrase() const
00184 { return fReasonPhrase; }
00186
00187
00188
00193
00201 inline HTTPResponseHeader&
00202 getHTTPVersion(const std::string& http_version)
00203 { fHTTPVersion = http_version; return *this; }
00204
00212 inline HTTPResponseHeader&
00213 getStatusCode(int status_code)
00214 { fStatusCode = status_code; return *this; }
00215
00223 inline HTTPResponseHeader&
00224 getReasonPhrase(const std::string& reason_phrase)
00225 { fReasonPhrase = reason_phrase; return *this; }
00227
00228
00229
00232 virtual void
00233 render(std::ostream& out) const;
00235
00236 private:
00237 HTTPResponseHeader();
00238
00239 std::string fHTTPVersion;
00240 int fStatusCode;
00241 std::string fReasonPhrase;
00242 std::vector<std::string> fHeaders;
00243 std::vector<HTTPCookie> fCookies;
00244 };
00245
00246 }
00247
00248 #endif