]> git.tdb.fi Git - libs/net.git/blob - source/client.h
Style update: spaces around assignments
[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 public:
25         sigc::signal<void, const Response &> signal_response_complete;
26         sigc::signal<void, int> signal_socket_error;
27
28 private:
29         Net::StreamSocket *sock;
30         IO::EventDispatcher *event_disp;
31         std::string user_agent;
32         Request *request;
33         Response *response;
34         std::string in_buf;
35
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 set_user_agent(const std::string &);
44         void start_request(const Request &);
45         const Response *get_url(const std::string &);
46         void tick();
47         void wait_response();
48         void abort();
49         const Request *get_request() const { return request; }
50         const Response *get_response() const { return response; }
51 private:
52         void connect_finished(int);
53         void data_available();
54 };
55
56 } // namespace Http
57 } // namespace Msp
58
59 #endif