EVHttpServer  1.0.0
A Lightweight http server base libevent and threadpool
Public Member Functions | List of all members
EVHttpServer::HttpReq Class Reference

HttpReq is an encapsulation class for http requests, which provides access to method, path, body, etc. It is not allowed to be created externally. Some components of the uri do not provide access functions. More...

#include <EVHttpServer.h>

Public Member Functions

ReqType method () const
 Get http request method. More...
 
std::string methodStr () const
 Get http request method string. More...
 
std::string path () const
 Get http request path. More...
 
std::string body () const
 Get http request body. More...
 
std::unique_ptr< char[]> bodyRaw () const
 Get http request body raw data. More...
 
std::string uri () const
 Get http request uri. More...
 
std::string host () const
 Get http request host. More...
 
void headers (std::list< HttpKeyVal > &ret) const
 Get http request headers. More...
 
bool findHeader (const std::string &key, std::string &value) const
 find header in http request More...
 
void querys (std::list< HttpKeyVal > &ret) const
 Get querys in http request. More...
 
bool findQuery (const std::string &key, std::string &value) const
 find http query More...
 

Detailed Description

HttpReq is an encapsulation class for http requests, which provides access to method, path, body, etc. It is not allowed to be created externally. Some components of the uri do not provide access functions.

Member Function Documentation

◆ body()

std::string EVHttpServer::HttpReq::body ( ) const

Get http request body.

Returns
body string

◆ bodyRaw()

std::unique_ptr< char[]> EVHttpServer::HttpReq::bodyRaw ( ) const

Get http request body raw data.

Returns
std::unique_ptr which provides raw data of body

◆ findHeader()

bool EVHttpServer::HttpReq::findHeader ( const std::string &  key,
std::string &  value 
) const

find header in http request

Parameters
[in]key: header name
[out]value: header value
Return values
true: find success
false: not found

◆ findQuery()

bool EVHttpServer::HttpReq::findQuery ( const std::string &  key,
std::string &  value 
) const

find http query

Parameters
[in]key: query name
[out]value: query value
Return values
true: find success
false: not found

◆ headers()

void EVHttpServer::HttpReq::headers ( std::list< HttpKeyVal > &  ret) const

Get http request headers.

Parameters
[out]ret: A list for storing http request headers
Returns
void

◆ host()

std::string EVHttpServer::HttpReq::host ( ) const

Get http request host.

Returns
Returns the host associated with the request. If a client sends an absolute URI, the host part of that is preferred. Otherwise, the input headers are searched for a Host: header. NULL is returned if no absolute URI or Host:header is provided.

◆ method()

EVHttpServer::ReqType EVHttpServer::HttpReq::method ( ) const

Get http request method.

Returns
The return value is the enumeration type of ReqType

◆ methodStr()

std::string EVHttpServer::HttpReq::methodStr ( ) const

Get http request method string.

Returns
The return value is after converting the ReqType(evhttp_cmd_type) enumeration type to a string, as listed below: "GET","POST","HEAD","PUT","DELETE","OPTIONS","TRACE","CONNECT","PATCH"

◆ path()

std::string EVHttpServer::HttpReq::path ( ) const

Get http request path.

Returns
path string

◆ querys()

void EVHttpServer::HttpReq::querys ( std::list< HttpKeyVal > &  ret) const

Get querys in http request.

Parameters
[out]ret: A list for storing http request querys
Returns
void

◆ uri()

std::string EVHttpServer::HttpReq::uri ( ) const

Get http request uri.

Returns
uri string

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