Github   Telegram
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
server::http::HttpRequest Class Referencefinal

HTTP Request data. More...

#include <userver/server/http/http_request.hpp>

Public Types

using HeadersMap = std::unordered_map< std::string, std::string, utils::StrIcaseHash, utils::StrIcaseEqual >
 
using HeadersMapKeys = decltype(utils::impl::MakeKeysView(HeadersMap()))
 
using CookiesMap = std::unordered_map< std::string, std::string >
 
using CookiesMapKeys = decltype(utils::impl::MakeKeysView(CookiesMap()))
 

Public Member Functions

HttpResponseGetHttpResponse () const
 Returns a container that should be filled with response data to this request.
 
const HttpMethodGetMethod () const
 
const std::string & GetMethodStr () const
 
int GetHttpMajor () const
 
int GetHttpMinor () const
 
const std::string & GetUrl () const
 
const std::string & GetRequestPath () const
 
const std::string & GetPathSuffix () const
 
std::chrono::duration< double > GetRequestTime () const
 
std::chrono::duration< double > GetResponseTime () const
 
const std::string & GetHost () const
 
const std::string & GetArg (const std::string &arg_name) const
 
const std::vector< std::string > & GetArgVector (const std::string &arg_name) const
 
bool HasArg (const std::string &arg_name) const
 
size_t ArgCount () const
 
std::vector< std::string > ArgNames () const
 
const FormDataArgGetFormDataArg (const std::string &arg_name) const
 
const std::vector< FormDataArg > & GetFormDataArgVector (const std::string &arg_name) const
 
bool HasFormDataArg (const std::string &arg_name) const
 
size_t FormDataArgCount () const
 
std::vector< std::string > FormDataArgNames () const
 
const std::string & GetPathArg (const std::string &arg_name) const
 
const std::string & GetPathArg (size_t index) const
 
bool HasPathArg (const std::string &arg_name) const
 
bool HasPathArg (size_t index) const
 
size_t PathArgCount () const
 
const std::string & GetHeader (const std::string &header_name) const
 
bool HasHeader (const std::string &header_name) const
 
size_t HeaderCount () const
 
HeadersMapKeys GetHeaderNames () const
 
const std::string & GetCookie (const std::string &cookie_name) const
 
bool HasCookie (const std::string &cookie_name) const
 
size_t CookieCount () const
 
CookiesMapKeys GetCookieNames () const
 
const std::string & RequestBody () const
 
void SetResponseStatus (HttpStatus status) const
 Set the response status code. More...
 
bool IsBodyCompressed () const
 

Detailed Description

HTTP Request data.

Examples
samples/config_service/config_service.cpp, samples/flatbuf_service/flatbuf_service.cpp, samples/grpc_service/grpc_service.cpp, samples/hello_service/hello_service.cpp, samples/http_caching/http_caching.cpp, samples/mongo_service/mongo_service.cpp, samples/postgres_service/postgres_service.cpp, samples/redis_service/redis_service.cpp, samples/testsuite-support/src/logcapture.cpp, samples/testsuite-support/src/metrics.cpp, samples/testsuite-support/src/metrics.hpp, samples/testsuite-support/src/now.cpp, and samples/testsuite-support/src/testpoint.cpp.

Definition at line 26 of file http_request.hpp.

Member Typedef Documentation

◆ CookiesMap

using server::http::HttpRequest::CookiesMap = std::unordered_map<std::string, std::string>

Definition at line 34 of file http_request.hpp.

◆ CookiesMapKeys

using server::http::HttpRequest::CookiesMapKeys = decltype(utils::impl::MakeKeysView(CookiesMap()))

Definition at line 36 of file http_request.hpp.

◆ HeadersMap

using server::http::HttpRequest::HeadersMap = std::unordered_map<std::string, std::string, utils::StrIcaseHash, utils::StrIcaseEqual>

Definition at line 28 of file http_request.hpp.

◆ HeadersMapKeys

using server::http::HttpRequest::HeadersMapKeys = decltype(utils::impl::MakeKeysView(HeadersMap()))

Definition at line 32 of file http_request.hpp.

Member Function Documentation

◆ ArgCount()

size_t server::http::HttpRequest::ArgCount ( ) const
Returns
Count of arguments. Arguments are extracted from query part of the URL and from the HTTP body.

◆ ArgNames()

std::vector< std::string > server::http::HttpRequest::ArgNames ( ) const
Returns
List of names of arguments. Arguments are extracted from query part of the URL and from the HTTP body.

◆ CookieCount()

size_t server::http::HttpRequest::CookieCount ( ) const
Returns
Number of cookies.

◆ FormDataArgCount()

size_t server::http::HttpRequest::FormDataArgCount ( ) const
Returns
Count of multipart/form-data arguments.

◆ FormDataArgNames()

std::vector< std::string > server::http::HttpRequest::FormDataArgNames ( ) const
Returns
List of names of multipart/form-data arguments.

◆ GetArg()

const std::string & server::http::HttpRequest::GetArg ( const std::string &  arg_name) const
Returns
First argument value with name arg_name or an empty string if no such argument. Arguments are extracted from query part of the URL and from the HTTP body.
Examples
samples/http_caching/http_caching.cpp, samples/mongo_service/mongo_service.cpp, samples/postgres_service/postgres_service.cpp, and samples/redis_service/redis_service.cpp.

◆ GetArgVector()

const std::vector< std::string > & server::http::HttpRequest::GetArgVector ( const std::string &  arg_name) const
Returns
Argument values with name arg_name or an empty string if no such argument. Arguments are extracted from query part of the URL and from the HTTP body.

◆ GetCookie()

const std::string & server::http::HttpRequest::GetCookie ( const std::string &  cookie_name) const
Returns
Value of the cookie with case sensitive name cookie_name, or an empty string if no such cookie exists.

◆ GetCookieNames()

CookiesMapKeys server::http::HttpRequest::GetCookieNames ( ) const
Returns
List of cookies names.

◆ GetFormDataArg()

const FormDataArg & server::http::HttpRequest::GetFormDataArg ( const std::string &  arg_name) const
Returns
First argument value with name arg_name from multipart/form-data request or an empty FormDataArg if no such argument.

◆ GetFormDataArgVector()

const std::vector< FormDataArg > & server::http::HttpRequest::GetFormDataArgVector ( const std::string &  arg_name) const
Returns
Argument values with name arg_name from multipart/form-data request or an empty FormDataArg if no such argument.

◆ GetHeader()

const std::string & server::http::HttpRequest::GetHeader ( const std::string &  header_name) const
Returns
Value of the header with case insensitive name header_name, or an empty string if no such header.

◆ GetHeaderNames()

HeadersMapKeys server::http::HttpRequest::GetHeaderNames ( ) const
Returns
List of headers names.

◆ GetHost()

const std::string & server::http::HttpRequest::GetHost ( ) const
Returns
Host from the URL.

◆ GetHttpMajor()

int server::http::HttpRequest::GetHttpMajor ( ) const
Returns
Major version of HTTP. For example, for HTTP 1.0 it returns 1

◆ GetHttpMinor()

int server::http::HttpRequest::GetHttpMinor ( ) const
Returns
Minor version of HTTP. For example, for HTTP 1.0 it returns 0

◆ GetPathArg() [1/2]

const std::string & server::http::HttpRequest::GetPathArg ( const std::string &  arg_name) const
Returns
Named argument from URL path with wildcards.

◆ GetPathArg() [2/2]

const std::string & server::http::HttpRequest::GetPathArg ( size_t  index) const
Returns
Argument from URL path with wildcards by its 0-based index

◆ GetPathSuffix()

const std::string & server::http::HttpRequest::GetPathSuffix ( ) const
Returns
Request path suffix, i.e. part of the path that remains after matching the path of a handler.

◆ GetRequestPath()

const std::string & server::http::HttpRequest::GetRequestPath ( ) const
Returns
Request path

◆ GetUrl()

const std::string & server::http::HttpRequest::GetUrl ( ) const
Returns
Request URL

◆ HasArg()

bool server::http::HttpRequest::HasArg ( const std::string &  arg_name) const
Returns
true if argument with name arg_name exists, false otherwise. Arguments are extracted from query part of the URL and from the HTTP body.
Examples
samples/mongo_service/mongo_service.cpp.

◆ HasCookie()

bool server::http::HttpRequest::HasCookie ( const std::string &  cookie_name) const
Returns
true if cookie with case sensitive name cookie_name exists, false otherwise.

◆ HasFormDataArg()

bool server::http::HttpRequest::HasFormDataArg ( const std::string &  arg_name) const
Returns
true if argument with name arg_name exists in multipart/form-data request, false otherwise.

◆ HasHeader()

bool server::http::HttpRequest::HasHeader ( const std::string &  header_name) const
Returns
true if header with case insensitive name header_name exists, false otherwise.

◆ HasPathArg() [1/2]

bool server::http::HttpRequest::HasPathArg ( const std::string &  arg_name) const
Returns
true if named argument from URL path with wildcards exists, false otherwise.

◆ HasPathArg() [2/2]

bool server::http::HttpRequest::HasPathArg ( size_t  index) const
Returns
true if argument with index from URL path with wildcards exists, false otherwise.

◆ HeaderCount()

size_t server::http::HttpRequest::HeaderCount ( ) const
Returns
Number of headers.

◆ IsBodyCompressed()

bool server::http::HttpRequest::IsBodyCompressed ( ) const
Returns
true if the body of the request was compressed

◆ PathArgCount()

size_t server::http::HttpRequest::PathArgCount ( ) const
Returns
Number of wildcard arguments in URL path.

◆ RequestBody()

const std::string & server::http::HttpRequest::RequestBody ( ) const
Returns
HTTP body.
Examples
samples/grpc_service/grpc_service.cpp.

◆ SetResponseStatus()

void server::http::HttpRequest::SetResponseStatus ( HttpStatus  status) const

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