Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
kcenon::network::protocols::http2::http2_response Struct Reference

HTTP/2 response data. More...

#include <http2_client.h>

Collaboration diagram for kcenon::network::protocols::http2::http2_response:
Collaboration graph

Public Member Functions

auto get_header (const std::string &name) const -> std::optional< std::string >
 Get header value by name.
 
auto get_body_string () const -> std::string
 Get body as string.
 

Public Attributes

int status_code = 0
 HTTP status code.
 
std::vector< http_headerheaders
 Response headers.
 
std::vector< uint8_t > body
 Response body.
 

Detailed Description

HTTP/2 response data.

Definition at line 46 of file http2_client.h.

Member Function Documentation

◆ get_body_string()

auto kcenon::network::protocols::http2::http2_response::get_body_string ( ) const -> std::string

Get body as string.

Returns
Body as UTF-8 string

Definition at line 38 of file http2_client.cpp.

39 {
40 return std::string(body.begin(), body.end());
41 }
std::vector< uint8_t > body
Response body.

References body.

◆ get_header()

auto kcenon::network::protocols::http2::http2_response::get_header ( const std::string & name) const -> std::optional<std::string>

Get header value by name.

Parameters
nameHeader name (case-insensitive)
Returns
Header value if found

Definition at line 17 of file http2_client.cpp.

18 {
19 std::string lower_name = name;
20 std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(),
21 [](unsigned char c) { return std::tolower(c); });
22
23 for (const auto& header : headers)
24 {
25 std::string lower_header_name = header.name;
26 std::transform(lower_header_name.begin(), lower_header_name.end(),
27 lower_header_name.begin(),
28 [](unsigned char c) { return std::tolower(c); });
29
30 if (lower_header_name == lower_name)
31 {
32 return header.value;
33 }
34 }
35 return std::nullopt;
36 }
std::vector< http_header > headers
Response headers.

References kcenon::network::protocols::http2::headers.

Member Data Documentation

◆ body

std::vector<uint8_t> kcenon::network::protocols::http2::http2_response::body

◆ headers

std::vector<http_header> kcenon::network::protocols::http2::http2_response::headers

◆ status_code


The documentation for this struct was generated from the following files: