📄 warsvrprotocolhttpheader.h
字号:
/** */#if WAR_RFC2068#ifndef WAR_SVR_PROTOCOL_HTTP_HEADER_H#define WAR_SVR_PROTOCOL_HTTP_HEADER_H/* SYSTEM INCLUDES */#ifndef WAR_MAP_INCLUDED# define WAR_MAP_INCLUDED# include <map>#endif/* PROJECT INCLUDES */#ifndef WAR_EXCEPTION_H# include "WarException.h"#endif#ifndef WAR_SVR_PROTOCOL_HTTP_ENUMS_H# include "WarSvrProtocolHttpEnums.h"#endif#ifndef WAR_URL_H# include "WarUrl.h"#endif#ifndef WAR_COLLECTOR_H# include "WarCollector.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarSvrProtocolHttpHeader :public WarSvrProtocolHttpEnums{public: typedef std::map<std::string, std::string> hdrmap_t; typedef std::pair<std::string, std::string> hdrpair_t; // LIFECYCLE /** * Default constructor. */ WarSvrProtocolHttpHeader(); /** * Copy constructor. * * @param from The value to copy to this object. */ WarSvrProtocolHttpHeader(const WarSvrProtocolHttpHeader& from); /** * Destructor. */ ~WarSvrProtocolHttpHeader(); // OPERATORS /** * Assignment operator. * * @param from THe value to assign to this object. * * @return A reference to this object. */ WarSvrProtocolHttpHeader& operator = (const WarSvrProtocolHttpHeader& from); /** Parse a request-header and set header fields. * * The header string must be terminated by an empty * line. */ WarSvrProtocolHttpHeader& operator << (war_ccstr_t hdrStr) throw(WarException); // OPERATIONS void Set(const std::string& name, const std::string value) throw (WarException); void SetReplyCode(const HttpReplyCodeE& value); void SetHttpVersion(const HttpVersionE& value); void SetContentLength(const war_int64_t& length); void VaildateHeaders(); void Reset(); void SetDefaultUrl(const WarUrl& newDefaultUrl); template <class ostrT> void GetNativeHeaders(ostrT& out) throw (WarException) { // Normal header lines for(hdrmap_t::const_iterator P = mHeaders.begin() ; P != mHeaders.end() ; ++P) { out << P->first << ": " << P->second << "\r\n"; } } template <class ostrT> void GetServerHeaders(ostrT& out) throw (WarException) { VaildateHeaders(); // Response line out << GetVersionName() << ' ' << (int)mReturnValue << ' ' << GetResponseText() << "\r\n"; // Normal header lines GetNativeHeaders(out); out << "\r\n"; } // CALLBACK // ACCESS const WarUrl& GetUrl() const { return mRequestUrl; } // INQUIRY const std::string& GetHeaderValue(war_ccstr_t name) const throw (WarException); bool IsSet(war_ccstr_t name) const; war_ccstr_t GetVersionName() const; war_ccstr_t GetMethodName() const; war_ccstr_t GetResponseText() const; HttpMethodsE GetMethod() const { return mRequestMethod; } inline HttpVersionE GetHttpVersion() const { return mHttpVersion; } protected: hdrmap_t mHeaders; HttpVersionE mHttpVersion; HttpReplyCodeE mReturnValue; std::string mRequestUri; // Unparsed WarUrl mRequestUrl; // Parsed down WarUrl mDefaultUrl; // The servers URL HttpMethodsE mRequestMethod; static const war_ccstr_t mMethodNames[HM_INVALID]; static const war_ccstr_t mHttpVersionNames[HM_INVALID]; war_ccstr_t ParseRequestLine(war_ccstr_t str) throw(WarException); war_ccstr_t ParseHdrLine(war_ccstr_t str) throw(WarException); void ParseUrl();private:};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif /* WAR_SVR_PROTOCOL_HTTP_HEADER_H_ */#endif // #if WAR_RFC2068
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -