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

Represents an HTTP request message. More...

#include <http_types.h>

Collaboration diagram for kcenon::network::internal::http_request:
Collaboration graph

Public Member Functions

auto get_header (const std::string &name) const -> std::optional< std::string >
 Get the value of a header (case-insensitive)
 
auto set_header (const std::string &name, const std::string &value) -> void
 Set a header value.
 
auto get_body_string () const -> std::string
 Get body as string.
 
auto set_body_string (const std::string &content) -> void
 Set body from string.
 

Public Attributes

http_method method = http_method::HTTP_GET
 
std::string uri
 
http_version version = http_version::HTTP_1_1
 
std::map< std::string, std::string > headers
 
std::vector< uint8_t > body
 
std::map< std::string, std::string > query_params
 
std::map< std::string, std::string > cookies
 
std::map< std::string, std::string > form_data
 
std::map< std::string, multipart_filefiles
 

Detailed Description

Represents an HTTP request message.

Structure

  • method: HTTP method (GET, POST, etc.)
  • uri: Request URI (e.g., "/api/users")
  • version: HTTP version (1.0, 1.1, 2.0)
  • headers: Map of header name to value
  • body: Request body as raw bytes
  • query_params: Parsed query parameters from URI

Definition at line 111 of file http_types.h.

Member Function Documentation

◆ get_body_string()

auto kcenon::network::internal::http_request::get_body_string ( ) const -> std::string

Get body as string.

Returns
Body content as UTF-8 string

Definition at line 57 of file http_types.cpp.

58 {
59 return std::string(body.begin(), body.end());
60 }

References body.

◆ get_header()

auto kcenon::network::internal::http_request::get_header ( const std::string & name) const -> std::optional<std::string>

Get the value of a header (case-insensitive)

Parameters
nameHeader name
Returns
Optional header value

Definition at line 24 of file http_types.cpp.

25 {
26 auto lower_name = to_lower(name);
27 for (const auto& [key, value] : headers)
28 {
29 if (to_lower(key) == lower_name)
30 {
31 return value;
32 }
33 }
34 return std::nullopt;
35 }
std::map< std::string, std::string > headers
Definition http_types.h:116

Referenced by kcenon::network::core::http_client::build_request().

Here is the caller graph for this function:

◆ set_body_string()

auto kcenon::network::internal::http_request::set_body_string ( const std::string & content) -> void

Set body from string.

Parameters
contentBody content as UTF-8 string

Definition at line 62 of file http_types.cpp.

63 {
64 body.assign(content.begin(), content.end());
65 }

◆ set_header()

auto kcenon::network::internal::http_request::set_header ( const std::string & name,
const std::string & value ) -> void

Set a header value.

Parameters
nameHeader name
valueHeader value

Definition at line 37 of file http_types.cpp.

38 {
39 // Remove existing header with same name (case-insensitive)
40 auto lower_name = to_lower(name);
41 for (auto it = headers.begin(); it != headers.end();)
42 {
43 if (to_lower(it->first) == lower_name)
44 {
45 it = headers.erase(it);
46 }
47 else
48 {
49 ++it;
50 }
51 }
52
53 // Add new header
54 headers[name] = value;
55 }

Referenced by kcenon::network::core::http_client::build_request().

Here is the caller graph for this function:

Member Data Documentation

◆ body

std::vector<uint8_t> kcenon::network::internal::http_request::body

◆ cookies

std::map<std::string, std::string> kcenon::network::internal::http_request::cookies

Definition at line 119 of file http_types.h.

◆ files

std::map<std::string, multipart_file> kcenon::network::internal::http_request::files

Definition at line 121 of file http_types.h.

◆ form_data

std::map<std::string, std::string> kcenon::network::internal::http_request::form_data

Definition at line 120 of file http_types.h.

◆ headers

std::map<std::string, std::string> kcenon::network::internal::http_request::headers

Definition at line 116 of file http_types.h.

◆ method

◆ query_params

std::map<std::string, std::string> kcenon::network::internal::http_request::query_params

◆ uri

◆ version


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