restcgi::method Class Reference

List of all members.

Detailed Description

HTTP method class.

This is returned from the endpoint object when the request is received and contains all the information needed to determine the client request and return a response.

An application can use this class and associated classes by themselves to return a response. Alternatively, the resource class and functions may be employed to provide a REST framework for locating a resource and applying the method to it.

For clients that cannot create PUT or DELETE HTTP requests a POST request with query params (values ignored) of restPUT and restDELETE are interpreted as such with the method object adjusted accordingly.

Example code:

 #include <restcgi/endpoint.h>
 #include <restcgi/method.h>
 using namespace restcgi;
 ...
 method::pointer m = endpoint::create()->receive();
 if (m->e() == method_e::GET) ...
See also:
http://www.w3.org/Protocols/rfc2616/rfc2616.html

endpoint, rest, resource


Public Types

typedef boost::shared_ptr<
method
pointer
 shared ptr
typedef boost::shared_ptr<
const method
const_pointer
 const shared ptr
typedef restcgi::env env_type
 env type
typedef restcgi::endpoint endpoint_type
 endpoint type
typedef boost::shared_ptr<
endpoint_type
endpoint_pointer
 shared endpoint ptr
typedef restcgi::icontent icontent_type
 iconent type
typedef restcgi::ocontent ocontent_type
 oconent type
typedef boost::shared_ptr<
icontent_type
icontent_pointer
 shared icontent ptr
typedef boost::shared_ptr<
ocontent_type
ocontent_pointer
 shared ocontent ptr
typedef restcgi::request_hdr request_hdr_type
 request header type
typedef restcgi::response_hdr response_hdr_type
 response header type
typedef uripp::path uri_path_type
 URI path type.
typedef uripp::query uri_query_type
 URI query type.

Public Member Functions

const method_ee () const
 Get method enumeration.
const uri_path_typeuri_path () const
 Get URI path.
const uri_query_typeuri_query () const
 Get URI query.
const request_hdr_typerequest_hdr () const
 Get request header.
icontent_pointer icontent () const
 Get input content stream.
ocontent_pointer ocontent () const
 Get output content stream (must respond first).
void respond (const status_code_e &sc=status_code_e::OK, const response_hdr_type &rh=response_hdr_type())
 Send the response header, no content will be sent.
ocontent_pointer respond (const content_hdr &ch, const status_code_e &sc=status_code_e::OK, const response_hdr_type &rh=response_hdr_type())
 Send the response and content header and create the stream for sending the content itself.
bool responded () const
 Test if responded.
const env_typeenv () const
 Get environment.
endpoint_pointer endpoint () const
 Get endpoint.

Static Public Attributes

static const char QP_REST_PUT [8]
 query param for PUT method ("restPUT")
static const char QP_REST_DELETE [11]
 query param for DELETE method ("restDELETE")

Friends

class endpoint


Member Function Documentation

ocontent_pointer restcgi::method::respond ( const content_hdr ch,
const status_code_e sc = status_code_e::OK,
const response_hdr_type rh = response_hdr_type() 
)

Send the response and content header and create the stream for sending the content itself.

Exceptions:
std::domain_error if already responded

void restcgi::method::respond ( const status_code_e sc = status_code_e::OK,
const response_hdr_type rh = response_hdr_type() 
)

Send the response header, no content will be sent.

Exceptions:
std::domain_error if already responded

const uri_path_type& restcgi::method::uri_path (  )  const [inline]

Get URI path.

This is the path starting after the CGI script name, i.e. it is the env::path_info().


Generated on Fri May 15 11:27:12 2009 for restcgi by  doxygen 1.4.7