]> git.tdb.fi Git - libs/net.git/blob - source/client.h
Initial revision
[libs/net.git] / source / client.h
1 /* $Id$
2
3 This file is part of libmsphttp
4 Copyright © 2008  Mikkosoft Productions, Mikko Rasa
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_HTTP_CLIENT_H_
9 #define MSP_HTTP_CLIENT_H_
10
11 #include <string>
12 #include <sigc++/signal.h>
13 #include <msp/io/eventdispatcher.h>
14 #include <msp/net/streamsocket.h>
15
16 namespace Msp {
17 namespace Http {
18
19 class Request;
20 class Response;
21
22 class Client
23 {
24 private:
25         Net::StreamSocket *sock;
26         IO::EventDispatcher *event_disp;
27         Request *request;
28         Response *response;
29         std::string in_buf;
30
31 public:
32         sigc::signal<void, const Response &> signal_response_complete;
33         sigc::signal<void, int> signal_socket_error;
34
35 private:
36         Client(const Client &);
37         Client &operator=(const Client &);
38 public:
39         Client();
40         ~Client();
41
42         void use_event_dispatcher(IO::EventDispatcher *);
43         void start_request(const Request &);
44         void get_url(const std::string &);
45         void tick();
46         void wait_response();
47         void abort();
48         const Request *get_request() const { return request; }
49         const Response *get_response() const { return response; }
50 private:
51         void connect_finished(int);
52         void data_available();
53 };
54
55 } // namespace Http
56 } // namespace Msp
57
58 #endif