4 #ifndef _libiqxmlrpc_http_h_
5 #define _libiqxmlrpc_http_h_
10 #include <boost/function.hpp>
11 #include <boost/shared_ptr.hpp>
18 class Auth_Plugin_base;
32 #pragma warning(disable: 4251)
42 unsigned content_length()
const;
43 bool conn_keep_alive()
const;
44 bool expect_continue()
const;
46 void set_content_length(
size_t ln );
47 void set_conn_keep_alive(
bool );
48 void set_option(
const std::string& name,
const std::string& value);
51 std::string dump()
const;
54 bool option_exists(
const std::string&)
const;
55 void set_option_default(
const std::string& name,
const std::string& value);
56 void set_option_default(
const std::string& name,
unsigned value);
57 void set_option_checked(
const std::string& name,
const std::string& value);
58 void set_option(
const std::string& name,
size_t value);
60 const std::string& get_head_line()
const {
return head_line_; }
61 std::string get_string(
const std::string& name)
const;
62 unsigned get_unsigned(
const std::string& name)
const;
68 typedef boost::function<void (const std::string&)> Option_validator_fn;
70 void register_validator(
75 void parse(
const std::string&);
79 T get_option(
const std::string& name)
const;
81 virtual std::string dump_head()
const = 0;
84 struct Option_validator {
86 Option_validator_fn fn;
89 typedef std::map<std::string, std::string> Options;
90 typedef std::multimap<std::string, Option_validator> Validators;
92 std::string head_line_;
94 Validators validators_;
108 Request_header(
const std::string& uri,
const std::string& vhost,
int port );
110 const std::string& uri()
const {
return uri_; }
111 std::string host()
const;
112 std::string agent()
const;
114 bool has_authinfo()
const;
115 void get_authinfo(std::string& user, std::string& password)
const;
116 void set_authinfo(
const std::string& user,
const std::string& password);
119 virtual std::string dump_head()
const;
131 int code()
const {
return code_; }
132 const std::string& phrase()
const {
return phrase_; }
133 std::string server()
const;
136 std::string current_date()
const;
137 virtual std::string dump_head()
const;
141 #pragma warning(push)
142 #pragma warning(disable: 4251)
148 boost::shared_ptr<http::Header> header_;
149 std::string content_;
157 void set_keep_alive(
bool =
true );
159 const http::Header* header()
const {
return header_.get(); }
160 const std::string& content()
const {
return content_; }
162 std::string dump()
const
164 return header_->
dump() + content_;
170 #pragma warning(disable: 4251)
176 std::string header_cache;
177 std::string content_cache;
192 continue_sent_(
false)
207 void set_max_size(
size_t m )
212 bool expect_continue()
const;
213 Packet* read_request(
const std::string& );
214 Packet* read_response(
const std::string&,
bool read_header_only );
215 void set_continue_sent();
219 void check_sz(
size_t );
220 bool read_header(
const std::string& );
222 template <
class Header_type>
223 Packet* read_packet(
const std::string&,
bool =
false );
231 Exception(
"Malformed HTTP packet received.") {}
234 Exception(
"Malformed HTTP packet received (" + problem_domain +
")." ) {}
253 std::string dump_error_response()
const {
return dump(); }