8 #ifndef _HTTP_SENDER_H_
9 #define _HTTP_SENDER_H_
28 virtual bool handle_response(std::shared_ptr<http_response> response) = 0;
31 template <
class handler_type>
46 if (EV_READ & events) {
50 m_handler = std::make_shared<handler_type>();
55 }
else if (EV_WRITE & events) {
79 inline void send(std::shared_ptr<http_request> request) {
81 const std::string& host =
m_request->header(
"Host");
82 tdbg(
"http_sender: Sending request to " << host << std::endl);
88 tdbg(
"http_sender: Closing connection to " <<
m_host <<
":" <<
m_port << std::endl);
117 #endif // _HTTP_SENDER_H_
static std::shared_ptr< dispatcher > instance()
The HTTP response implementation.
std::shared_ptr< http_request > m_request
The net_io_task implements the base for socket based network tasks.
virtual bool handle_response(std::shared_ptr< http_response > response)=0
std::shared_ptr< handler_type > m_handler
int events() const
Return the monitored events.
virtual void update_watcher(worker *worker)
Udate a watcher in the context of the given worker.
http_sender(std::shared_ptr< handler_type > handler)
net::socket & socket()
Provide access to the underlying socket object.
bool handle_event(tasks::worker *worker, int events)
void set_exception(tasks_exception &e)
Set an exception to report an error.
std::shared_ptr< http_response > m_response
virtual void stop_watcher(worker *worker)
Stop a watcher in the context of the given worker.
void send(std::shared_ptr< http_request > request)
void connect(std::string path)
void set_events(int events)
Update the events the object monitors.