00001 // $Id: HTTP_Response.h 90737 2010-06-21 09:46:14Z mcorino $ 00002 00003 /** 00004 * @file HTTP_Response.h 00005 * 00006 * @author Martin Corino <mcorino@remedy.nl> 00007 */ 00008 00009 #ifndef ACE_HTTP_RESPONSE_H 00010 #define ACE_HTTP_RESPONSE_H 00011 00012 #include /**/ "ace/pre.h" 00013 00014 #include /**/ "ace/config-all.h" 00015 00016 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00017 # pragma once 00018 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00019 00020 #include "ace/Array.h" 00021 #include "ace/INet/INet_Export.h" 00022 #include "ace/INet/Response.h" 00023 #include "ace/INet/HTTP_Header.h" 00024 #include "ace/INet/HTTP_Status.h" 00025 00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00027 00028 namespace ACE 00029 { 00030 namespace HTTP 00031 { 00032 /** 00033 * @class ACE_HTTP_Response 00034 * 00035 * @brief Encapsulates HTTP response message properties. 00036 * 00037 */ 00038 class ACE_INET_Export Response 00039 : public ACE::INet::Response, public Header 00040 { 00041 public: 00042 /// Constructor 00043 Response(); 00044 00045 Response(const Status& status); 00046 00047 Response(const ACE_CString& version, const Status& status = Status()); 00048 00049 /// Destructor 00050 virtual ~Response(); 00051 00052 /// Reset the response object 00053 void reset (); 00054 00055 void reset (const Status& status); 00056 00057 void reset (const ACE_CString& version, const Status& status = Status()); 00058 00059 /// Set the status. 00060 void set_status(const Status& status); 00061 00062 /// Return the status. 00063 const Status& get_status() const; 00064 00065 /// Adds a Cookie header. 00066 void add_cookie(const ACE_CString& cookie); 00067 00068 /// Get cookies from Cookie header(s)). 00069 void get_cookies(ACE_Array<ACE_CString> & cookies) const; 00070 00071 /// Writes the HTTP response to the given stream 00072 virtual void write(std::ostream& str) const; 00073 00074 /// Reads the HTTP response from the 00075 /// given stream. 00076 /// 100 Continue responses are ignored. 00077 virtual bool read(std::istream& str); 00078 00079 static const ACE_CString COOKIE; 00080 00081 private: 00082 enum Limits 00083 { 00084 MAX_VERSION_LENGTH = 8, 00085 MAX_STATUS_LENGTH = 3, 00086 MAX_REASON_LENGTH = 512 00087 }; 00088 00089 Status status_; 00090 }; 00091 } 00092 } 00093 00094 ACE_END_VERSIONED_NAMESPACE_DECL 00095 00096 #if defined (__ACE_INLINE__) 00097 #include "ace/INet/HTTP_Response.inl" 00098 #endif 00099 00100 #include /**/ "ace/post.h" 00101 #endif /* ACE_HTTP_RESPONSE_H */