# pion::http::response_writer Class Reference

`#include <response_writer.hpp>`

Inherits pion::http::writer.

List of all members.

## Public Member Functions

virtual | ~response_writer ()
| default destructor
http::response & | get_response (void)
| returns a non-const reference to the response that will be sent

## Static Public Member Functions

static boost::shared_ptr < response_writer > | create (tcp::connection_ptr &tcp_conn, http::response_ptr &http_response_ptr, finished_handler_t handler=finished_handler_t())
static boost::shared_ptr < response_writer > | create (tcp::connection_ptr &tcp_conn, const http::request &http_request, finished_handler_t handler=finished_handler_t())

## Protected Member Functions

| response_writer (tcp::connection_ptr &tcp_conn, http::response_ptr &http_response_ptr, finished_handler_t handler)
| response_writer (tcp::connection_ptr &tcp_conn, const http::request &http_request, finished_handler_t handler)
virtual void | prepare_buffers_for_send (http::message::write_buffers_t &write_buffers)
virtual write_handler_t | bind_to_write_handler (void)
| returns a function bound to http::writer::handle_write()
virtual void | handle_write (const boost::system::error_code &write_error, std::size_t bytes_written)

## Detailed Description

response_writer: used to asynchronously send HTTP responses

Definition at line 31 of file response_writer.hpp.

## Constructor & Destructor Documentation

pion::http::response_writer::response_writer | ( | tcp::connection_ptr & | tcp_conn,
|  | http::response_ptr & | http_response_ptr,
|  | finished_handler_t | handler |
| ) |  |  | `[inline, protected]`

protected constructor restricts creation of objects (use create())

Parameters:

  | tcp_conn | TCP connection used to send the response
  | http_response | pointer to the response that will be sent
  | handler | function called after the request has been sent

Definition at line 87 of file response_writer.hpp.

pion::http::response_writer::response_writer | ( | tcp::connection_ptr & | tcp_conn,
|  | const http::request & | http_request,
|  | finished_handler_t | handler |
| ) |  |  | `[inline, protected]`

protected constructor restricts creation of objects (use create())

Parameters:

  | tcp_conn | TCP connection used to send the response
  | http_request | the request we are responding to
  | handler | function called after the request has been sent

Definition at line 111 of file response_writer.hpp.

## Member Function Documentation

static boost::shared_ptr<response_writer> pion::http::response_writer::create | ( | tcp::connection_ptr & | tcp_conn,
|  | const http::request & | http_request,
|  | finished_handler_t | handler = `finished_handler_t()` |
| ) |  |  | `[inline, static]`

creates new response_writer objects

Parameters:

  | tcp_conn | TCP connection used to send the response
  | http_request | the request we are responding to
  | handler | function called after the request has been sent

Returns:
  boost::shared_ptr<response_writer> shared pointer to the new writer object that was created

Definition at line 67 of file response_writer.hpp.

static boost::shared_ptr<response_writer> pion::http::response_writer::create | ( | tcp::connection_ptr & | tcp_conn,
|  | http::response_ptr & | http_response_ptr,
|  | finished_handler_t | handler = `finished_handler_t()` |
| ) |  |  | `[inline, static]`

creates new response_writer objects

Parameters:

  | tcp_conn | TCP connection used to send the response
  | http_response | pointer to the response that will be sent
  | handler | function called after the response has been sent

Returns:
  boost::shared_ptr<response_writer> shared pointer to the new writer object that was created

Definition at line 50 of file response_writer.hpp.

Referenced by pion::http::server::handle_bad_request(), pion::http::server::handle_forbidden_request(), pion::http::server::handle_method_not_allowed(), pion::http::server::handle_not_found_request(), pion::http::cookie_auth::handle_ok(), pion::http::cookie_auth::handle_redirection(), pion::http::server::handle_server_error(), pion::http::cookie_auth::handle_unauthorized(), pion::http::basic_auth::handle_unauthorized(), pion::plugins::LogService::operator()(), pion::plugins::HelloService::operator()(), pion::plugins::FileService::operator()(), pion::plugins::EchoService::operator()(), pion::plugins::CookieService::operator()(), and pion::plugins::AllowNothingService::operator()().

virtual void pion::http::response_writer::handle_write | ( | const boost::system::error_code & | write_error,
|  | std::size_t | bytes_written |
| ) |  |  | `[inline, protected, virtual]`

called after the response is sent

Parameters:

  | write_error | error status from the last write operation
  | bytes_written | number of bytes sent by the last write operation

Implements pion::http::writer.

Definition at line 147 of file response_writer.hpp.

Referenced by bind_to_write_handler().

virtual void pion::http::response_writer::prepare_buffers_for_send | ( | http::message::write_buffers_t & | write_buffers | ) | `[inline, protected, virtual]`

initializes a vector of write buffers with the HTTP message information

Parameters:

  | write_buffers | vector of write buffers to initialize

Implements pion::http::writer.

Definition at line 126 of file response_writer.hpp.

The documentation for this class was generated from the following file:

- include/pion/http/response_writer.hpp