asio 0.3.8rc3 Home | Reference | Tutorial | Examples | Design
Examples

http::server::reply Struct Reference

List of all members.


Detailed Description

A reply to be sent to a client.

Definition at line 23 of file reply.hpp.


Public Types

enum  status_type {
  ok = 200,
  created = 201,
  accepted = 202,
  no_content = 204,
  multiple_choices = 300,
  moved_permanently = 301,
  moved_temporarily = 302,
  not_modified = 304,
  bad_request = 400,
  unauthorized = 401,
  forbidden = 403,
  not_found = 404,
  internal_server_error = 500,
  not_implemented = 501,
  bad_gateway = 502,
  service_unavailable = 503
}
 The status of the reply. More...

Public Member Functions

std::vector< asio::const_bufferto_buffers ()
 Convert the reply into a vector of buffers. The buffers do not own the underlying memory blocks, therefore the reply object must remain valid and not be changed until the write operation has completed.

Static Public Member Functions

static reply stock_reply (status_type status)
 Get a stock reply.

Public Attributes

enum
http::server::reply::status_type 
status
 The status of the reply.
std::vector< headerheaders
 The headers to be included in the reply.
std::string content
 The content to be sent in the reply.

Member Enumeration Documentation

enum http::server::reply::status_type

The status of the reply.

Enumerator:
ok 
created 
accepted 
no_content 
multiple_choices 
moved_permanently 
moved_temporarily 
not_modified 
bad_request 
unauthorized 
forbidden 
not_found 
internal_server_error 
not_implemented 
bad_gateway 
service_unavailable 

Definition at line 26 of file reply.hpp.

00027   {
00028     ok = 200,
00029     created = 201,
00030     accepted = 202,
00031     no_content = 204,
00032     multiple_choices = 300,
00033     moved_permanently = 301,
00034     moved_temporarily = 302,
00035     not_modified = 304,
00036     bad_request = 400,
00037     unauthorized = 401,
00038     forbidden = 403,
00039     not_found = 404,
00040     internal_server_error = 500,
00041     not_implemented = 501,
00042     bad_gateway = 502,
00043     service_unavailable = 503
00044   } status;


Member Function Documentation

std::vector< asio::const_buffer > http::server::reply::to_buffers (  ) 

Convert the reply into a vector of buffers. The buffers do not own the underlying memory blocks, therefore the reply object must remain valid and not be changed until the write operation has completed.

Definition at line 103 of file reply.cpp.

Referenced by http::server::connection::handle_read().

00104 {
00105   std::vector<asio::const_buffer> buffers;
00106   buffers.push_back(status_strings::to_buffer(status));
00107   for (std::size_t i = 0; i < headers.size(); ++i)
00108   {
00109     header& h = headers[i];
00110     buffers.push_back(asio::buffer(h.name));
00111     buffers.push_back(asio::buffer(misc_strings::name_value_separator));
00112     buffers.push_back(asio::buffer(h.value));
00113     buffers.push_back(asio::buffer(misc_strings::crlf));
00114   }
00115   buffers.push_back(asio::buffer(misc_strings::crlf));
00116   buffers.push_back(asio::buffer(content));
00117   return buffers;
00118 }

reply http::server::reply::stock_reply ( reply::status_type  status  )  [static]

Get a stock reply.

Definition at line 242 of file reply.cpp.

Referenced by http::server::connection::handle_read(), and http::server::request_handler::handle_request().

00243 {
00244   reply rep;
00245   rep.status = status;
00246   rep.content = stock_replies::to_string(status);
00247   rep.headers.resize(2);
00248   rep.headers[0].name = "Content-Length";
00249   rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size());
00250   rep.headers[1].name = "Content-Type";
00251   rep.headers[1].value = "text/html";
00252   return rep;
00253 }


Member Data Documentation

enum http::server::reply::status_type http::server::reply::status

The status of the reply.

Referenced by http::server::request_handler::handle_request(), stock_reply(), and to_buffers().

std::vector<header> http::server::reply::headers

The headers to be included in the reply.

Definition at line 47 of file reply.hpp.

Referenced by http::server::request_handler::handle_request(), stock_reply(), and to_buffers().

std::string http::server::reply::content

The content to be sent in the reply.

Definition at line 50 of file reply.hpp.

Referenced by http::server::request_handler::handle_request(), stock_reply(), and to_buffers().


The documentation for this struct was generated from the following files:
asio 0.3.8rc3 Home | Reference | Tutorial | Examples | Design