userver: server::http Namespace Reference
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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
 

Enumerations

enum class  HttpMethod {
  kDelete ,
  kGet ,
  kHead ,
  kPost ,
  kPut ,
  kPatch ,
  kConnect ,
  kOptions ,
  kUnknown
}
 List of HTTP methods. More...
 
enum class  HttpStatus {
  kContinue = 100 ,
  kSwitchingProtocols = 101 ,
  kProcessing = 102 ,
  kOk = 200 ,
  kCreated = 201 ,
  kAccepted = 202 ,
  kNonAuthoritativeInformation = 203 ,
  kNoContent = 204 ,
  kResetContent = 205 ,
  kPartialContent = 206 ,
  kMultiStatus = 207 ,
  kAlreadyReported = 208 ,
  kImUsed = 226 ,
  kMultipleChoices = 300 ,
  kMovedPermanently = 301 ,
  kFound = 302 ,
  kSeeOther = 303 ,
  kNotModified = 304 ,
  kUseProxy = 305 ,
  kTemporaryRedirect = 307 ,
  kPermanentRedirect = 308 ,
  kBadRequest = 400 ,
  kUnauthorized = 401 ,
  kPaymentRequired = 402 ,
  kForbidden = 403 ,
  kNotFound = 404 ,
  kMethodNotAllowed = 405 ,
  kNotAcceptable = 406 ,
  kProxyAuthenticationRequired = 407 ,
  kRequestTimeout = 408 ,
  kConflict = 409 ,
  kGone = 410 ,
  kLengthRequired = 411 ,
  kPreconditionFailed = 412 ,
  kPayloadTooLarge = 413 ,
  kUriTooLong = 414 ,
  kUnsupportedMediaType = 415 ,
  kRangeNotSatisfiable = 416 ,
  kExpectationFailed = 417 ,
  kImATeapot = 418 ,
  kMisdirectedRequest = 421 ,
  kUnprocessableEntity = 422 ,
  kLocked = 423 ,
  kFailedDependency = 424 ,
  kTooEarly = 425 ,
  kUpgradeRequired = 426 ,
  kPreconditionRequired = 428 ,
  kTooManyRequests = 429 ,
  kRequestHeaderFieldsTooLarge = 431 ,
  kUnavailableForLegalReasons = 451 ,
  kDeadlineExpired = 498 ,
  kClientClosedRequest = 499 ,
  kInternalServerError = 500 ,
  kNotImplemented = 501 ,
  kBadGateway = 502 ,
  kServiceUnavailable = 503 ,
  kGatewayTimeout = 504 ,
  kHttpVersionNotSupported = 505 ,
  kVariantAlsoNegotiates = 506 ,
  kInsufficientStorage = 507 ,
  kLoopDetected = 508 ,
  kNotExtended = 510 ,
  kNetworkAuthenticationRequired = 511
}
 HTTP status codes. 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)
 
std::string ToString (HttpStatus status)
 

Enumeration Type Documentation

◆ HttpMethod

enum class server::http::HttpMethod
strong

List of HTTP methods.

Definition at line 16 of file http_method.hpp.

◆ HttpStatus

enum class server::http::HttpStatus
strong

HTTP status codes.

Definition at line 15 of file http_status.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.