EHS Embedded HTTP Server  1.5.1.173
HttpRequest Class Reference

This class represents a clients HTTP request. More...

#include <httprequest.h>

Public Member Functions

virtual ~HttpRequest ()
 Destructor.
 
std::string RemoteAddress ()
 Retrieves the peer's IP address. More...
 
int RemotePort ()
 Retrieves the peer's port. More...
 
std::string LocalAddress ()
 Retrieves the local IP address. More...
 
int LocalPort ()
 Retrieves the local port. More...
 
std::string Address ()
 Retrieves the peer's IP address. More...
 
int Port ()
 Retrieves the peer's port. More...
 
int Id () const
 Retrieves this request's Id. More...
 
EHSConnectionConnection () const
 Retrieves the receiving connection. More...
 
RequestMethod Method () const
 Retrieves the request method. More...
 
bool Secure () const
 Retrieves the security status. More...
 
bool ClientDisconnected ()
 Retrieves the client connection status. More...
 
const std::string & Uri () const
 Retrieves this request's URI. More...
 
const std::string & HttpVersion () const
 Retrieves the HTTP version. More...
 
const std::string & Body () const
 Retrieves this request's body. More...
 
StringCaseMap & Headers ()
 Retrieves HTTP headers. More...
 
FormValueMap & FormValues ()
 Retrieves form values. More...
 
CookieMap & Cookies ()
 Retrieves cookies. More...
 
FormValueFormValues (const std::string &name)
 Retrieves a specific form value. More...
 
std::string Headers (const std::string &name)
 Retrieves a specific HTTP header. More...
 
void SetHeader (const std::string &name, const std::string &value)
 Sets a single request header. More...
 
std::string Cookies (const std::string &name)
 Retrieves a specific cookie value. More...
 

Friends

class EHSConnection
 
class EHS
 

Detailed Description

This class represents a clients HTTP request.

It contans pre-parsed data like cookies, form data and header information.

Examples:
ehs_basicauth.cpp, ehs_exception.cpp, ehs_formtest.cpp, ehs_mirror.cpp, ehs_privport.cpp, ehs_test.cpp, ehs_testharness.cpp, ehs_uploader.cpp, and ehs_wsgate.cpp.

Definition at line 51 of file httprequest.h.

Member Function Documentation

◆ Address()

std::string Address ( )
inline

Retrieves the peer's IP address.

Returns
The IP address of the peer that sent this request as dot-quad.
Deprecated:
Use RemoteAddress()

Definition at line 99 of file httprequest.h.

References RemoteAddress().

+ Here is the call graph for this function:

◆ Body()

const std::string& Body ( ) const
inline

Retrieves this request's body.

Returns
The body content of this request.
Examples:
ehs_basicauth.cpp, ehs_privport.cpp, and ehs_testharness.cpp.

Definition at line 155 of file httprequest.h.

◆ ClientDisconnected()

bool ClientDisconnected ( )

Retrieves the client connection status.

Returns
true if the client is disconnected.

◆ Connection()

EHSConnection* Connection ( ) const
inline

Retrieves the receiving connection.

Returns
The connection on which this request was received.

Definition at line 119 of file httprequest.h.

◆ Cookies() [1/2]

CookieMap& Cookies ( )
inline

Retrieves cookies.

Returns
All cookies of this request.
Examples:
ehs_basicauth.cpp, ehs_privport.cpp, ehs_test.cpp, ehs_testharness.cpp, and ehs_uploader.cpp.

Definition at line 173 of file httprequest.h.

◆ Cookies() [2/2]

std::string Cookies ( const std::string &  name)
inline

Retrieves a specific cookie value.

Parameters
nameThe name of the cookie to be retrieved.
Returns
The value of the specified cookie.

Definition at line 215 of file httprequest.h.

◆ FormValues() [1/2]

FormValueMap& FormValues ( )
inline

Retrieves form values.

Returns
All form values of this request.
Examples:
ehs_basicauth.cpp, ehs_formtest.cpp, ehs_privport.cpp, ehs_testharness.cpp, and ehs_uploader.cpp.

Definition at line 167 of file httprequest.h.

◆ FormValues() [2/2]

FormValue& FormValues ( const std::string &  name)
inline

Retrieves a specific form value.

Parameters
nameThe name of the form element to be retrieved.
Returns
The value of the specified form element.

Definition at line 180 of file httprequest.h.

◆ Headers() [1/2]

StringCaseMap& Headers ( )
inline

Retrieves HTTP headers.

Returns
A StringCaseMap of the HTTP headers from this request.
Examples:
ehs_basicauth.cpp, ehs_privport.cpp, ehs_testharness.cpp, and ehs_wsgate.cpp.

Definition at line 161 of file httprequest.h.

◆ Headers() [2/2]

std::string Headers ( const std::string &  name)
inline

Retrieves a specific HTTP header.

Parameters
nameThe name of the HTTP header to be retrieved.
Returns
The value of the specified header.

Definition at line 190 of file httprequest.h.

◆ HttpVersion()

const std::string& HttpVersion ( ) const
inline

Retrieves the HTTP version.

Returns
The HTTP version string as received in the request header.
Examples:
ehs_basicauth.cpp, ehs_privport.cpp, ehs_testharness.cpp, and ehs_wsgate.cpp.

Definition at line 149 of file httprequest.h.

◆ Id()

int Id ( ) const
inline

Retrieves this request's Id.

Returns
The unique Id that was generated by EHS.

Definition at line 113 of file httprequest.h.

◆ LocalAddress()

std::string LocalAddress ( )

Retrieves the local IP address.

Returns
The local IP address where this request was received as dot-quad.

◆ LocalPort()

int LocalPort ( )

Retrieves the local port.

Returns
The local port where this request was received.

◆ Method()

RequestMethod Method ( ) const
inline

Retrieves the request method.

Returns
The numeric request method of this request.
Examples:
ehs_basicauth.cpp, ehs_privport.cpp, ehs_testharness.cpp, and ehs_wsgate.cpp.

Definition at line 125 of file httprequest.h.

◆ Port()

int Port ( )
inline

Retrieves the peer's port.

Returns
The peer port that sent this request.
Deprecated:
Use RemotePort()

Definition at line 107 of file httprequest.h.

References RemotePort().

+ Here is the call graph for this function:

◆ RemoteAddress()

std::string RemoteAddress ( )

Retrieves the peer's IP address.

Returns
The IP address of the peer that sent this request as dot-quad.
Examples:
ehs_basicauth.cpp, ehs_mirror.cpp, ehs_privport.cpp, and ehs_testharness.cpp.

Referenced by Address().

+ Here is the caller graph for this function:

◆ RemotePort()

int RemotePort ( )

Retrieves the peer's port.

Returns
The peer port that sent this request.
Examples:
ehs_basicauth.cpp, ehs_mirror.cpp, ehs_privport.cpp, and ehs_testharness.cpp.

Referenced by Port().

+ Here is the caller graph for this function:

◆ Secure()

bool Secure ( ) const
inline

Retrieves the security status.

Returns
true if this request was received via SSL, false otherwise.
Examples:
ehs_mirror.cpp.

Definition at line 131 of file httprequest.h.

◆ SetHeader()

void SetHeader ( const std::string &  name,
const std::string &  value 
)
inline

Sets a single request header.

This method is intended for generating synthetic headers (for example when implementing HTTP basic authentication).

Parameters
nameThe name of the HTTP header to be set.
valueThe value of the HTTP header to be set.
Examples:
ehs_basicauth.cpp.

Definition at line 205 of file httprequest.h.

◆ Uri()

const std::string& Uri ( ) const
inline

Retrieves this request's URI.

Returns
The request URI of this request.
Examples:
ehs_basicauth.cpp, ehs_exception.cpp, ehs_privport.cpp, ehs_testharness.cpp, ehs_uploader.cpp, and ehs_wsgate.cpp.

Definition at line 143 of file httprequest.h.


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