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

HttpRes is the encapsulation class of http response, which provides methods for setting body, head, code, etc. It is not allowed to be created externally. More...

#include <EVHttpServer.h>

Public Member Functions

bool setBody (const std::string &body)
 set http response body More...
 
bool addHeader (const HttpKeyVal &header)
 Add http reply header (single) More...
 
bool addHeaders (const std::list< HttpKeyVal > &list)
 Add the headers of the http reply. Unlike setHeaders, this function will not clear the previously set headers. More...
 
bool setHeaders (const std::list< HttpKeyVal > &list)
 set http response headers More...
 
void setCode (const int &code)
 Set the HTTP response code to send. More...
 
void setReason (const std::string &reason)
 Set reason which is a brief message to send with the response code. More...
 

Detailed Description

HttpRes is the encapsulation class of http response, which provides methods for setting body, head, code, etc. It is not allowed to be created externally.

Member Function Documentation

◆ addHeader()

bool EVHttpServer::HttpRes::addHeader ( const HttpKeyVal header)

Add http reply header (single)

Parameters
[in]header: A header to reply to the http client
Return values
true: set success
false: set failed

◆ addHeaders()

bool EVHttpServer::HttpRes::addHeaders ( const std::list< HttpKeyVal > &  list)

Add the headers of the http reply. Unlike setHeaders, this function will not clear the previously set headers.

Parameters
[in]list: header list
Return values
true: set success
false: set failed

◆ setBody()

bool EVHttpServer::HttpRes::setBody ( const std::string &  body)

set http response body

Parameters
[in]body: response body
Return values
true: set success
false: set failed

◆ setCode()

void EVHttpServer::HttpRes::setCode ( const int &  code)

Set the HTTP response code to send.

Parameters
[in]code: the HTTP response code to send
Returns
void

◆ setHeaders()

bool EVHttpServer::HttpRes::setHeaders ( const std::list< HttpKeyVal > &  list)

set http response headers

Parameters
[in]list: header list
Return values
true: set success
false: set failed

◆ setReason()

void EVHttpServer::HttpRes::setReason ( const std::string &  reason)

Set reason which is a brief message to send with the response code.

Parameters
[in]reason: a brief message to send with the response code
Returns
void

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