1 #ifndef MSP_HTTP_CLIENT_H_
2 #define MSP_HTTP_CLIENT_H_
5 #include <sigc++/signal.h>
6 #include <msp/io/eventdispatcher.h>
7 #include <msp/net/resolve.h>
8 #include <msp/net/streamsocket.h>
13 class client_busy: public std::logic_error
16 client_busy(): std::logic_error(std::string()) { }
17 virtual ~client_busy() throw() { }
26 sigc::signal<void, const Response &> signal_response_complete;
27 sigc::signal<void, const std::exception &> signal_socket_error;
30 struct ResolveListener: public sigc::trackable
34 ResolveListener(Client &);
36 void address_resolved(unsigned, const Net::SockAddr &);
37 void resolve_failed(unsigned, const std::exception &);
40 Net::StreamSocket *sock;
41 IO::EventDispatcher *event_disp;
42 Net::Resolver *resolver;
43 ResolveListener *resolve_listener;
45 std::string user_agent;
50 Client(const Client &);
51 Client &operator=(const Client &);
56 void use_event_dispatcher(IO::EventDispatcher *);
57 void use_resolver(Net::Resolver *);
58 void set_user_agent(const std::string &);
59 void start_request(const Request &);
60 const Response *get_url(const std::string &);
64 const Request *get_request() const { return request; }
65 const Response *get_response() const { return response; }
67 void address_resolved(unsigned, const Net::SockAddr &);
68 void resolve_failed(unsigned, const std::exception &);
69 void connect_finished(const std::exception *);
70 void data_available();