00001 /***************************************************************************** 00002 * Copyright (C) 2011 by Benjamin Hadorn (b_hadorn@bluewin.ch) 00003 ***************************************************************************** 00004 * Project : Zeus Base Library 00005 * Module : HTTPResponse 00006 * Package : Zeus.ZeusBase.Net.Protocols 00007 * Author : Benjamin Hadorn 00008 * Date : 27.12.2011 00009 * System : Zeus-Framework 00010 ***************************************************************************** 00011 * Licence: * 00012 * This library is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU Lesser General Public License as * 00014 * published by the Free Software Foundation; either version * 00015 * 2.1 of the License, or (at your option) any later version. * 00016 * * 00017 * This library is distributed in the hope that it will be useful, * 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00020 * GNU Lesser General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU Lesser General Public * 00023 * License along with this library; if not, write to the Free Software * 00024 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * 00025 *****************************************************************************/ 00026 00027 /***************************************************************************** 00028 * Changes: 00029 * 27.12.2011 bha: created zeus 2.0 00030 *****************************************************************************/ 00031 00032 #ifndef HTTPResponseH 00033 #define HTTPResponseH 00034 00035 #include <zeusbase/Net/Protocols/AbstractHTTPData.h> 00036 00037 BEGIN_NAMESPACE_Zeus 00038 00039 /***************************************************************************/ 00042 /***************************************************************************/ 00043 zeusbase_class THTTPResponse : public TAbstractHTTPData 00044 { 00045 public: 00046 /***********************************************************************/ 00050 /***********************************************************************/ 00051 enum EResponseProperty 00052 { 00053 /*HTTP 1.0*/ 00054 etLocation = 0, 00055 etServer = 1, 00056 etWWWAuthenticate = 2, 00057 00058 /*Additional HTTP 1.0 Fields*/ 00059 etRetryAfter = 3 00060 }; 00061 00062 THTTPResponse(THTTProtocol::EHTTPVersion eVersion = THTTProtocol::etVersion_1_0); 00063 00064 virtual void reset(); 00065 virtual Retval setResponseProperty(EResponseProperty eType, const IString& rValue); 00066 00067 THTTProtocol::EResponseState getState() const; 00068 void setState(THTTProtocol::EResponseState eState); 00069 void setStateWithMessage(THTTProtocol::EResponseState eState, const IString& rMessage); 00070 TString toString() const; 00071 bool isBinary() const; 00072 void getBinaryData(IByteArray& rData) const; 00073 void setBinaryData(const IByteArray& rData); 00074 00075 static Retval parse(const IString& rIn, THTTPResponse*& rpResponse); 00076 00077 protected: 00078 virtual ~THTTPResponse(); 00079 00080 private: 00082 THTTProtocol::EResponseState m_eState; 00084 bool m_bBinaryContent; 00086 TByteArray m_aData; 00087 }; 00088 00089 //inline methods 00090 /***************************************************************************/ 00093 /***************************************************************************/ 00094 inline THTTProtocol::EResponseState THTTPResponse::getState() const 00095 { 00096 return m_eState; 00097 } 00098 00099 /***************************************************************************/ 00102 /***************************************************************************/ 00103 inline void THTTPResponse::setState(THTTProtocol::EResponseState eState) 00104 { 00105 m_eState = eState; 00106 } 00107 00108 /***************************************************************************/ 00111 /***************************************************************************/ 00112 inline bool THTTPResponse::isBinary() const 00113 { 00114 return m_bBinaryContent; 00115 } 00116 00117 00118 00119 00120 END_NAMESPACE_Zeus 00121 00122 #endif