#ifndef _WININET_HTTPHEADER_HPP_ #define _WININET_HTTPHEADER_HPP_ #ifndef _COMMON_BLOCK_HPP_ #include #endif #ifndef _COMMON_STRING_HPP_ #include #endif #ifndef _WININET_SERIALIZEABLE_HPP_ #include #endif class ContentType { public: typedef enum ContentTypeConst{MultipartFormData,ApplicationWWWFormURLEncoded}; static String getContentType(ContentTypeConst contentTypeConst); }; inline String ContentType::getContentType(ContentTypeConst contentTypeConst) { switch(contentTypeConst) { case MultipartFormData : return "multipart/form-data"; case ApplicationWWWFormURLEncoded : default : return "application/x-www-form-urlencoded"; } } class HTTPHeader : public Serializeable { public: HTTPHeader(); HTTPHeader(Block &headerLines); HTTPHeader(const String &headerLines); virtual ~HTTPHeader(); HTTPHeader &operator=(Block &headerLines); HTTPHeader &operator=(const String &headerLines); const String &getDate(void)const; void setDate(const String &date); const String &getServer(void)const; void setServer(const String &server); const String &getLastModified(void)const; void setLastModified(const String &lastModified); const String &getETag(void)const; void setETag(const String &eTag); int getContentLength(void)const; void setContentLength(int contentLength); const String &getContentType(void)const; void setContentType(const String &contentType); const String &getAccept(void)const; void setAccept(const String &accept); int getResponseCode(void)const; void setResponseCode(int responseCode); bool isErrorResponse(void)const; String getApplicationExtension(void)const; String serialize(void); private: void parseHeader(Block &headerLines); void parseHeader(const String &headerLines); void createHeaderLines(String strHeaders,Block &headerLines); String mDate; String mServer; String mLastModified; String mETag; String mAcceptRanges; int mContentLength; String mContentType; String mAccept; int mResponseCode; }; inline HTTPHeader::HTTPHeader() : mContentLength(0), mResponseCode(0), mContentType("application/x-www-form-urlencoded") { } inline HTTPHeader::HTTPHeader(Block &headerLines) { parseHeader(headerLines); } inline HTTPHeader::HTTPHeader(const String &headerLines) { parseHeader(headerLines); } inline HTTPHeader::~HTTPHeader() { } inline HTTPHeader &HTTPHeader::operator=(Block &headerLines) { parseHeader(headerLines); return *this; } inline HTTPHeader &HTTPHeader::operator=(const String &headerLines) { parseHeader(headerLines); return *this; } inline const String &HTTPHeader::getDate(void)const { return mDate; } inline void HTTPHeader::setDate(const String &date) { mDate=date; } inline const String &HTTPHeader::getServer(void)const { return mServer; } inline void HTTPHeader::setServer(const String &server) { mServer=server; } inline const String &HTTPHeader::getLastModified(void)const { return mLastModified; } inline void HTTPHeader::setLastModified(const String &lastModified) { mLastModified=lastModified; } inline const String &HTTPHeader::getETag(void)const { return mETag; } inline void HTTPHeader::setETag(const String &eTag) { mETag=eTag; } inline int HTTPHeader::getContentLength(void)const { return mContentLength; } inline void HTTPHeader::setContentLength(int contentLength) { mContentLength=contentLength; } inline const String &HTTPHeader::getContentType(void)const { return mContentType; } inline void HTTPHeader::setContentType(const String &contentType) { mContentType=contentType; } inline const String &HTTPHeader::getAccept(void)const { return mAccept; } inline void HTTPHeader::setAccept(const String &accept) { mAccept=accept; } inline int HTTPHeader::getResponseCode(void)const { return mResponseCode; } inline void HTTPHeader::setResponseCode(int responseCode) { mResponseCode=responseCode; } inline bool HTTPHeader::isErrorResponse(void)const { return getResponseCode()>=500; } #endif