userver: server::http Namespace Reference
Loading...
Searching...
No Matches
server::http Namespace Reference

Detailed Description

Server parts of the HTTP protocol implementation.

Classes

class  Cookie
 HTTP response cookie. More...
 
class  CustomHandlerException
 An extension of server::handlers::CustomHandlerException that allows to specify a custom HttpStatus. More...
 
struct  FormDataArg
 Argument of a multipart/form-data request. More...
 
class  HttpRequest
 HTTP Request data. More...
 
class  HttpResponse
 HTTP Response data. More...
 
class  ResponseBodyStream
 

Typedefs

using HttpStatus = ::http::StatusCode
 HTTP status codes.
 

Enumerations

enum class  HttpMethod {
  kDelete ,
  kGet ,
  kHead ,
  kPost ,
  kPut ,
  kPatch ,
  kConnect ,
  kOptions ,
  kUnknown
}
 List of HTTP methods. More...
 

Functions

HttpStatus GetHttpStatus (handlers::HandlerErrorCode) noexcept
 Get http status code mapped to generic handler error code.
 
HttpStatus GetHttpStatus (const handlers::CustomHandlerException &exception) noexcept
 
const std::string & ToString (HttpMethod method) noexcept
 Convert HTTP method enum value to string.
 
HttpMethod HttpMethodFromString (std::string_view method_str)
 Convert HTTP method string to enum value.
 
void SetThrottleReason (http::HttpResponse &http_response, std::string log_reason, std::string http_header_reason)
 
std::string_view HttpStatusString (HttpStatus status)
 

Variables

constexpr std::string_view kDefaultContentType = "application/octet-stream"
 

Typedef Documentation

◆ HttpStatus

HTTP status codes.

Definition at line 15 of file http_status.hpp.

Enumeration Type Documentation

◆ HttpMethod

enum class server::http::HttpMethod
strong

List of HTTP methods.

Definition at line 16 of file http_method.hpp.

Function Documentation

◆ GetHttpStatus() [1/2]

HttpStatus server::http::GetHttpStatus ( const handlers::CustomHandlerException & exception)
noexcept

For server::http::CustomHandlerException, uses the provided HttpStatus. For a generic server::handler::CustomHandlerException, converts its server::handler::HandlerErrorCode to HttpStatus.

◆ GetHttpStatus() [2/2]

HttpStatus server::http::GetHttpStatus ( handlers::HandlerErrorCode )
noexcept

Get http status code mapped to generic handler error code.

If there is no explicit mapping in the http_error.cpp, will return HttpStatus::kBadRequest for code values less than HandlerErrorCode::kServerSideError and will return HttpStatus::kInternalServerError for the rest of codes.

Variable Documentation

◆ kDefaultContentType

constexpr std::string_view server::http::kDefaultContentType = "application/octet-stream"
inlineconstexpr

Definition at line 31 of file http_response.hpp.