00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _httpheader_h
00018 #define _httpheader_h
00019
00020 #include <spl/Debug.h>
00021 #include <spl/collection/Association.h>
00022 #include <spl/collection/Hashtable.h>
00023 #include <spl/io/IStream.h>
00024 #include <spl/Memory.h>
00025 #include <spl/String.h>
00026 #include <spl/collection/Vector.h>
00027
00033 class HttpHeader : public IMemoryValidate
00034 {
00035 protected:
00036 Vector<Association<String, String> > m_headers;
00037 Hashtable<String, int> m_headerIdx;
00038
00039 public:
00040 inline HttpHeader(const HttpHeader& hdr)
00041 : m_headers(hdr.m_headers), m_headerIdx(hdr.m_headerIdx)
00042 {
00043 }
00044
00045 HttpHeader();
00046 virtual ~HttpHeader();
00047
00048 inline HttpHeader& operator =(const HttpHeader& hdr)
00049 {
00050 m_headers = hdr.m_headers;
00051 m_headerIdx = hdr.m_headerIdx;
00052 return *this;
00053 }
00054
00055 String& Header(const String& name);
00056
00057 inline bool HasHeader(const String& name) const
00058 {
00059 return m_headerIdx.ContainsKey(name);
00060 }
00061
00062 inline String& ContentLength()
00063 {
00064 return Header("Content-Length");
00065 }
00066
00067 inline String& ContentType()
00068 {
00069 return Header("Content-Type");
00070 }
00071
00072 inline int Count() const
00073 {
00074 return m_headers.Count();
00075 }
00076
00077 void ParseLine( const String& line );
00078
00079 void Write(spl::IStream& stream) const;
00080 StringPtr ToString() const;
00081
00082 #ifdef DEBUG
00083 virtual void ValidateMem() const;
00084 virtual void CheckMem() const;
00085 #endif
00086 };
00087
00090 #endif