Boost C++ Libraries Home Libraries People FAQ More

Home | Reference | Tutorial | Examples | Design

http::server::reply Struct Reference

List of all members.

Detailed Description

A reply to be sent to a client.

Definition at line 13 of file reply.hpp.

Public Types

 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
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< boost::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 16 of file reply.hpp.

00017   {
00018     ok = 200,
00019     created = 201,
00020     accepted = 202,
00021     no_content = 204,
00022     multiple_choices = 300,
00023     moved_permanently = 301,
00024     moved_temporarily = 302,
00025     not_modified = 304,
00026     bad_request = 400,
00027     unauthorized = 401,
00028     forbidden = 403,
00029     not_found = 404,
00030     internal_server_error = 500,
00031     not_implemented = 501,
00032     bad_gateway = 502,
00033     service_unavailable = 503
00034   } status;


Member Function Documentation

std::vector< boost::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 93 of file reply.cpp.

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

00094 {
00095   std::vector<boost::asio::const_buffer> buffers;
00096   buffers.push_back(status_strings::to_buffer(status));
00097   for (std::size_t i = 0; i < headers.size(); ++i)
00098   {
00099     header& h = headers[i];
00100     buffers.push_back(boost::asio::buffer(h.name));
00101     buffers.push_back(boost::asio::buffer(misc_strings::name_value_separator));
00102     buffers.push_back(boost::asio::buffer(h.value));
00103     buffers.push_back(boost::asio::buffer(misc_strings::crlf));
00104   }
00105   buffers.push_back(boost::asio::buffer(misc_strings::crlf));
00106   buffers.push_back(boost::asio::buffer(content));
00107   return buffers;
00108 }

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

Get a stock reply.

Definition at line 232 of file reply.cpp.

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

00233 {
00234   reply rep;
00235   rep.status = status;
00236   rep.content = stock_replies::to_string(status);
00237   rep.headers.resize(2);
00238   rep.headers[0].name = "Content-Length";
00239   rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size());
00240   rep.headers[1].name = "Content-Type";
00241   rep.headers[1].value = "text/html";
00242   return rep;
00243 }


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 37 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 40 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:
Copyright © 2003 - 2006 Christopher M. Kohlhoff

Home | Reference | Tutorial | Examples | Design