X-Git-Url: http://git.tdb.fi/?p=libs%2Fnet.git;a=blobdiff_plain;f=source%2Fhttp%2Fclient.h;fp=source%2Fhttp%2Fclient.h;h=ee10f8c1cb5a0e389d860c6b9c59ee6a45aeb9a4;hp=0000000000000000000000000000000000000000;hb=cf8d2e48581eeb8f1b83e8c48321a0bc2ffa6d83;hpb=d683ca0964182e9579838fec8d7d100eeabddee0 diff --git a/source/http/client.h b/source/http/client.h new file mode 100644 index 0000000..ee10f8c --- /dev/null +++ b/source/http/client.h @@ -0,0 +1,52 @@ +#ifndef MSP_HTTP_CLIENT_H_ +#define MSP_HTTP_CLIENT_H_ + +#include +#include +#include +#include + +namespace Msp { +namespace Http { + +class Request; +class Response; + +class Client +{ +public: + sigc::signal signal_response_complete; + sigc::signal signal_socket_error; + +private: + Net::StreamSocket *sock; + IO::EventDispatcher *event_disp; + std::string user_agent; + Request *request; + Response *response; + std::string in_buf; + + Client(const Client &); + Client &operator=(const Client &); +public: + Client(); + ~Client(); + + void use_event_dispatcher(IO::EventDispatcher *); + void set_user_agent(const std::string &); + void start_request(const Request &); + const Response *get_url(const std::string &); + void tick(); + void wait_response(); + void abort(); + const Request *get_request() const { return request; } + const Response *get_response() const { return response; } +private: + void connect_finished(const std::exception *); + void data_available(); +}; + +} // namespace Http +} // namespace Msp + +#endif