]> git.tdb.fi Git - libs/net.git/blobdiff - source/http/client.h
Use default member initializers where possible
[libs/net.git] / source / http / client.h
index 37acf0cfe0e3bb08d1483520e9a3cd7bc557dc76..c88ce32df2cd62b55f4c41a66db66e6295470d4b 100644 (file)
@@ -4,18 +4,12 @@
 #include <string>
 #include <sigc++/signal.h>
 #include <msp/io/eventdispatcher.h>
+#include <msp/net/resolve.h>
 #include <msp/net/streamsocket.h>
 
 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<void, const std::exception &> 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();
 };