HTTP response with a buffered body.
More...
#include <kaycxx/http/buffered_response.hpp>
|
| | buffered_response (int status_code, std::string body, std::vector< kaycxx::http::header > headers={}) |
| | Creates a buffered HTTP response.
|
| std::string_view | text () const &noexcept |
| | Returns a non-owning view of the response body without interpreting its contents.
|
| std::string | text () &&noexcept |
| | Moves the response body out of an expiring response.
|
| nlohmann::json | json () const |
| | Parses and returns the response body as JSON.
|
| 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::header > | headers () &&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.
|
|
| | 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_base & | operator= (const response_base &)=default |
| | Copies common HTTP response data.
|
|
response_base & | operator= (response_base &&) noexcept=default |
| | Moves common HTTP response data.
|
|
| ~response_base ()=default |
| | Destroys common HTTP response data.
|
HTTP response with a buffered body.
◆ buffered_response()
| kaycxx::http::buffered_response::buffered_response |
( |
int | status_code, |
|
|
std::string | body, |
|
|
std::vector< kaycxx::http::header > | headers = {} ) |
Creates a buffered HTTP response.
- Parameters
-
| status_code | HTTP status code. |
| body | Response body. |
| headers | Response headers. |
◆ json()
| nlohmann::json kaycxx::http::buffered_response::json |
( |
| ) |
const |
|
nodiscard |
Parses and returns the response body as JSON.
- Returns
- Parsed JSON value. An empty response body is returned as JSON null.
- Exceptions
-
| nlohmann::json::parse_error | When the response body does not contain valid JSON. |
◆ text() [1/2]
| std::string kaycxx::http::buffered_response::text |
( |
| ) |
&& |
|
nodiscardnoexcept |
Moves the response body out of an expiring response.
- Returns
- Response body.
◆ text() [2/2]
| std::string_view kaycxx::http::buffered_response::text |
( |
| ) |
const & |
|
nodiscardnoexcept |
Returns a non-owning view of the response body without interpreting its contents.
The returned view remains valid until this response is destroyed, moved from or assigned a new value.
- Returns
- View of the response body.
The documentation for this class was generated from the following file: