X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fhttp%2Fmessage.h;fp=source%2Fhttp%2Fmessage.h;h=4d2310273f8b3fd0e4b0014aede99623028cd023;hb=cf8d2e48581eeb8f1b83e8c48321a0bc2ffa6d83;hp=0000000000000000000000000000000000000000;hpb=d683ca0964182e9579838fec8d7d100eeabddee0;p=libs%2Fnet.git diff --git a/source/http/message.h b/source/http/message.h new file mode 100644 index 0000000..4d23102 --- /dev/null +++ b/source/http/message.h @@ -0,0 +1,47 @@ +#ifndef MSP_HTTP_MESSAGE_H_ +#define MSP_HTTP_MESSAGE_H_ + +#include +#include +#include +#include "version.h" + +namespace Msp { +namespace Http { + +class Message +{ +protected: + typedef std::map HeaderMap; + + Version http_version; + HeaderMap headers; + std::string content; + unsigned chunk_length; + bool complete; + Variant user_data; + + Message(); +public: + virtual ~Message() { } + + void set_header(const std::string &, const std::string &); + bool has_header(const std::string &) const; + const std::string &get_header(const std::string &) const; + void add_content(const std::string &); + const std::string &get_content() const { return content; } + void set_user_data(const Variant &); + const Variant &get_user_data() const { return user_data; } + bool is_complete() const { return complete; } + unsigned parse_content(const std::string &); + virtual std::string str() const = 0; +protected: + unsigned parse_headers(const std::string &); + std::string str_common() const; + std::string normalize_header_name(const std::string &) const; +}; + +} // namespace Http +} // namespace Msp + +#endif