userver: clients::http::Response Class Reference
Loading...
Searching...
No Matches
clients::http::Response Class Referencefinal

#include <userver/clients/http/response.hpp>

Detailed Description

Class that will be returned for successful request.

Definition at line 25 of file response.hpp.

Public Types

enum class  RaiseIncludeBody : std::uint8_t {
  kNo = 0 ,
  kYes = 1
}
 Configuration whether to include the response body in the exception in raise_for_status. More...
 
using CookiesMap = server::http::Cookie::CookiesMap
 

Public Member Functions

std::string & sink_string ()
 response string
 
std::string body () const &
 body as string
 
std::string && body () &&
 
std::string_view body_view () const
 body as string_view
 
const Headersheaders () const
 return reference to headers
 
Headersheaders ()
 
const CookiesMap & cookies () const
 
CookiesMap & cookies ()
 
Status status_code () const
 status_code
 
bool IsOk () const
 check status code
 
bool IsError () const
 
void raise_for_status (RaiseIncludeBody include_body=RaiseIncludeBody::kNo) const
 Raise an exception depending on the response status. The body of the response may be included in the exception depending on the.
 
LocalStats GetStats () const
 returns statistics on request execution like count of opened sockets, connect time...
 
void SetStats (const LocalStats &stats)
 
void SetStatusCode (Status status_code)
 

Static Public Member Functions

static void RaiseForStatus (int code, const LocalStats &stats)
 
static void RaiseForStatus (int code, const LocalStats &stats, std::string_view message)
 

Member Typedef Documentation

◆ CookiesMap

using clients::http::Response::CookiesMap = server::http::Cookie::CookiesMap

Definition at line 27 of file response.hpp.

Member Enumeration Documentation

◆ RaiseIncludeBody

enum class clients::http::Response::RaiseIncludeBody : std::uint8_t
strong

Configuration whether to include the response body in the exception in raise_for_status.

Definition at line 57 of file response.hpp.

Member Function Documentation

◆ body() [1/2]

std::string && clients::http::Response::body ( ) &&
inline

Definition at line 36 of file response.hpp.

◆ body() [2/2]

std::string clients::http::Response::body ( ) const &
inline

body as string

Definition at line 35 of file response.hpp.

◆ body_view()

std::string_view clients::http::Response::body_view ( ) const
inline

body as string_view

Definition at line 39 of file response.hpp.

◆ cookies() [1/2]

CookiesMap & clients::http::Response::cookies ( )
inline

Definition at line 45 of file response.hpp.

◆ cookies() [2/2]

const CookiesMap & clients::http::Response::cookies ( ) const
inline

Definition at line 44 of file response.hpp.

◆ headers() [1/2]

Headers & clients::http::Response::headers ( )
inline

Definition at line 43 of file response.hpp.

◆ headers() [2/2]

const Headers & clients::http::Response::headers ( ) const
inline

return reference to headers

Definition at line 42 of file response.hpp.

◆ IsError()

bool clients::http::Response::IsError ( ) const
inline

Definition at line 51 of file response.hpp.

◆ IsOk()

bool clients::http::Response::IsOk ( ) const
inline

check status code

Definition at line 50 of file response.hpp.

◆ raise_for_status()

void clients::http::Response::raise_for_status ( RaiseIncludeBody  include_body = RaiseIncludeBody::kNo) const

Raise an exception depending on the response status. The body of the response may be included in the exception depending on the.

Parameters
include_body.
Exceptions
HttpClientExceptionfor statuses [400; 500)
HttpServerExceptionfor statuses [500; 600)

◆ SetStats()

void clients::http::Response::SetStats ( const LocalStats stats)
inline

Definition at line 69 of file response.hpp.

◆ SetStatusCode()

void clients::http::Response::SetStatusCode ( Status  status_code)
inline

Definition at line 70 of file response.hpp.

◆ sink_string()

std::string & clients::http::Response::sink_string ( )
inline

response string

Definition at line 32 of file response.hpp.


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