X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmessage.h;h=4d2310273f8b3fd0e4b0014aede99623028cd023;hb=1c965907682f4714db7b952915cf5b6bf9b7f4c1;hp=c9dc618a61eb31ce05e972a89f09f49d38ce792c;hpb=070d56e7b0036ca2e4234eb06dcae83ebfb3df34;p=libs%2Fnet.git diff --git a/source/message.h b/source/message.h index c9dc618..4d23102 100644 --- a/source/message.h +++ b/source/message.h @@ -1,40 +1,44 @@ -/* $Id$ - -This file is part of libmsphttp -Copyright © 2008 Mikkosoft Productions, Mikko Rasa -Distributed under the LGPL -*/ - #ifndef MSP_HTTP_MESSAGE_H_ #define MSP_HTTP_MESSAGE_H_ +#include #include -#include "misc.h" +#include +#include "version.h" namespace Msp { namespace Http { class Message { -public: - virtual ~Message() { } - - void set_header(const std::string &, const std::string &); - const std::string &get_header(const std::string &) const; - const std::string &get_data() const { return data; } - bool get_complete() const { return complete; } - void add_data(const std::string &); - unsigned parse_data(const std::string &); - virtual std::string str() const =0; protected: + typedef std::map HeaderMap; + Version http_version; HeaderMap headers; - std::string data; + 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