X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fhttp%2Fclient.h;h=c88ce32df2cd62b55f4c41a66db66e6295470d4b;hb=6625cf0e574406425c35d33110f8d99617e902df;hp=37acf0cfe0e3bb08d1483520e9a3cd7bc557dc76;hpb=6af1bfce6dc53104c5406adef32d186384525ae3;p=libs%2Fnet.git diff --git a/source/http/client.h b/source/http/client.h index 37acf0c..c88ce32 100644 --- a/source/http/client.h +++ b/source/http/client.h @@ -4,18 +4,12 @@ #include #include #include +#include #include namespace Msp { namespace Http { -class client_busy: public std::logic_error -{ -public: - client_busy(): std::logic_error(std::string()) { } - virtual ~client_busy() throw() { } -}; - class Request; class Response; @@ -26,20 +20,33 @@ public: sigc::signal signal_socket_error; private: - Net::StreamSocket *sock; - IO::EventDispatcher *event_disp; - std::string user_agent; - Request *request; - Response *response; + struct ResolveListener: public sigc::trackable + { + Client &client; + + ResolveListener(Client &); + + void address_resolved(unsigned, const Net::SockAddr &); + void resolve_failed(unsigned, const std::exception &); + }; + + Net::StreamSocket *sock = 0; + IO::EventDispatcher *event_disp = 0; + Net::Resolver *resolver = 0; + ResolveListener *resolve_listener = 0; + unsigned resolve_tag = 0; + std::string user_agent = "libmspnet/1.0"; + Request *request = 0; + Response *response = 0; std::string in_buf; Client(const Client &); Client &operator=(const Client &); public: - Client(); ~Client(); void use_event_dispatcher(IO::EventDispatcher *); + void use_resolver(Net::Resolver *); void set_user_agent(const std::string &); void start_request(const Request &); const Response *get_url(const std::string &); @@ -49,6 +56,8 @@ public: const Request *get_request() const { return request; } const Response *get_response() const { return response; } private: + void address_resolved(unsigned, const Net::SockAddr &); + void resolve_failed(unsigned, const std::exception &); void connect_finished(const std::exception *); void data_available(); };