00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef TNT_HTTPMESSAGE_H
00031 #define TNT_HTTPMESSAGE_H
00032
00033 #include <tnt/messageheader.h>
00034 #include <tnt/httpheader.h>
00035 #include <tnt/cookie.h>
00036 #include <time.h>
00037
00038 namespace tnt
00039 {
00041 class HttpMessage
00042 {
00043 public:
00044 typedef Messageheader header_type;
00045
00046 private:
00047 unsigned short majorVersion;
00048 unsigned short minorVersion;
00049
00050 protected:
00051 header_type header;
00052 Cookies httpcookies;
00053
00054 public:
00055 HttpMessage()
00056 : majorVersion(1),
00057 minorVersion(0)
00058 { }
00059 virtual ~HttpMessage()
00060 { }
00061
00063 virtual void clear();
00064
00066 bool hasHeader(const char* key) const { return header.hasHeader(key); }
00067 bool hasHeader(const std::string& key) const { return header.hasHeader(key); }
00070 const char* getHeader(const char* key, const char* def = "") const;
00071
00073 unsigned short getMajorVersion() const
00074 { return majorVersion; }
00076 unsigned short getMinorVersion() const
00077 { return minorVersion; }
00079 void setVersion(unsigned short major, unsigned short minor)
00080 { majorVersion = major; minorVersion = minor; }
00081
00084 header_type::const_iterator header_begin() const
00085 { return header.begin(); }
00087 header_type::const_iterator header_end() const
00088 { return header.end(); }
00089
00091 void setHeader(const std::string& key, const std::string& value, bool replace = true)
00092 { header.setHeader(key, value, replace); }
00094 void removeHeader(const std::string& key)
00095 { header.removeHeader(key); }
00096
00098 std::string dumpHeader() const;
00100 void dumpHeader(std::ostream& out) const;
00101
00103 static std::string htdate(time_t t);
00105 static std::string htdate(struct ::tm* tm);
00107 static std::string htdateCurrent();
00108
00111 static bool checkUrl(const std::string& url);
00112 };
00113 }
00114
00115 #endif // TNT_HTTPMESSAGE_H