libcex
1.0.0
Modern C++11 embedded webserver library
|
Contains the current request and all of its preparsed properties. More...
#include <core.hpp>
Public Member Functions | |
Request (evhtp_request *req) | |
Constructs a new Response object. More... | |
Method | getMethod () |
Returns the request's HTTP method. | |
Protocol | getProtocol () |
Returns the HTTP protocol version (1.0 or 1.1) | |
int | getPort () |
Returns the port, if present in the URI. | |
const char * | getHost () |
Returns the hostname of the request. | |
const char * | getUrl () |
Returns the full URL of the request. | |
const char * | getPath () |
Returns the path-portion of the URL of the request. | |
const char * | getFile () |
Returns the file-portion of the URL of the request. | |
const char * | getMiddlewarePath () |
void | eachHeader (PairCallbackFunction cb) |
Iterates all HTTP headers of the request with the given callback function. More... | |
const char * | get (const char *name) |
Returns the value of a HTTP header. More... | |
void | eachQueryParam (PairCallbackFunction cb) |
Iterates all URL query parameters of the request with the given callback function. More... | |
const char * | getQueryParam (const char *name) |
Returns the value of a URL query parameter. More... | |
const char * | getBody () |
size_t | getBodyLength () |
Public Attributes | |
PropertyList | properties |
A list of properties of the current request. More... | |
Friends | |
class | Server |
class | Response |
class | Middleware |
Contains the current request and all of its preparsed properties.
Contains several accessor methods for retrieving header information, URL parameters or request bodies.
Example:
cex::Request::Request | ( | evhtp_request * | req | ) |
Constructs a new Response object.
req | The underlying libevhtp request object |
void cex::Request::eachHeader | ( | PairCallbackFunction | cb | ) |
Iterates all HTTP headers of the request with the given callback function.
cb | A PairCallbackFunction which is called for each header. If the callback function returns true , iteration is stopped. |
void cex::Request::eachQueryParam | ( | PairCallbackFunction | cb | ) |
Iterates all URL query parameters of the request with the given callback function.
cb | A PairCallbackFunction which is called for each parameter. If the callback function returns true , iteration is stopped. |
const char * cex::Request::get | ( | const char * | name | ) |
Returns the value of a HTTP header.
name | Name of the HTTP header to retrieve |
const char * cex::Request::getBody | ( | ) |
Returns the RAW body contents of the request (unparsed, can be binary data)
size_t cex::Request::getBodyLength | ( | ) |
Returns the length of RAW body contents (number of bytes)
const char * cex::Request::getMiddlewarePath | ( | ) |
Returns the path of the currently matched Middleware
const char * cex::Request::getQueryParam | ( | const char * | name | ) |
Returns the value of a URL query parameter.
name | Name of the parameter to retrieve |
PropertyList cex::Request::properties |
A list of properties of the current request.
Some properties are filled by libcex
:
basicUsername
- The username, if the request was made with HTTP basic authentication basicPassword
- The password, if the request was made with HTTP basic authentication [sessionid]
- The session ID of the current request. Its created by the cex::sessionHandler middleware function, and the name of the property corresponds to the name of the cookie/sessionID as given in the middleware options