kaycxx-http
HTTP client library
Loading...
Searching...
No Matches
kaycxx::http::response_base Class Reference

Common status and header data of an HTTP response. More...

#include <kaycxx/http/response_base.hpp>

Inheritance diagram for kaycxx::http::response_base:

Public Member Functions

int status_code () const noexcept
 Returns the HTTP status code.
const std::vector< kaycxx::http::header > & headers () const &noexcept
 Returns all response headers in their received order.
std::vector< kaycxx::http::headerheaders () &&noexcept
 Moves all response headers out of an expiring response.
std::optional< std::string_view > header (std::string_view name) const &noexcept
 Returns the first value of a response header using an ASCII case-insensitive name comparison.
std::optional< std::string > header (std::string_view name) &&noexcept
 Moves the first value of a response header out of an expiring response using an ASCII case-insensitive name comparison.
std::vector< std::string > headers (std::string_view name) const
 Returns all values of a response header using an ASCII case-insensitive name comparison.

Protected Member Functions

 response_base (int status_code, std::vector< kaycxx::http::header > headers)
 Creates common HTTP response data.
 response_base (const response_base &)=default
 Copies common HTTP response data.
 response_base (response_base &&) noexcept=default
 Moves common HTTP response data.
response_baseoperator= (const response_base &)=default
 Copies common HTTP response data.
response_baseoperator= (response_base &&) noexcept=default
 Moves common HTTP response data.
 ~response_base ()=default
 Destroys common HTTP response data.

Detailed Description

Common status and header data of an HTTP response.

Constructor & Destructor Documentation

◆ response_base()

kaycxx::http::response_base::response_base ( int status_code,
std::vector< kaycxx::http::header > headers )
protected

Creates common HTTP response data.

Parameters
status_codeHTTP status code.
headersResponse headers.

Member Function Documentation

◆ header() [1/2]

std::optional< std::string > kaycxx::http::response_base::header ( std::string_view name) &&
nodiscardnoexcept

Moves the first value of a response header out of an expiring response using an ASCII case-insensitive name comparison.

Parameters
nameHeader name.
Returns
First matching header value, or an empty optional when the header is absent.

◆ header() [2/2]

std::optional< std::string_view > kaycxx::http::response_base::header ( std::string_view name) const &
nodiscardnoexcept

Returns the first value of a response header using an ASCII case-insensitive name comparison.

The returned view remains valid until this response is destroyed, moved from or assigned a new value.

Parameters
nameHeader name.
Returns
First matching header value, or an empty optional when the header is absent.

◆ headers() [1/3]

std::vector< kaycxx::http::header > kaycxx::http::response_base::headers ( ) &&
nodiscardnoexcept

Moves all response headers out of an expiring response.

Returns
Response headers.

◆ headers() [2/3]

const std::vector< kaycxx::http::header > & kaycxx::http::response_base::headers ( ) const &
nodiscardnoexcept

Returns all response headers in their received order.

The returned reference remains valid until this response is destroyed, moved from or assigned a new value.

Returns
Response headers.

◆ headers() [3/3]

std::vector< std::string > kaycxx::http::response_base::headers ( std::string_view name) const
nodiscard

Returns all values of a response header using an ASCII case-insensitive name comparison.

Parameters
nameHeader name.
Returns
Matching header values in their received order.

◆ status_code()

int kaycxx::http::response_base::status_code ( ) const
nodiscardnoexcept

Returns the HTTP status code.

Returns
HTTP status code.

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