|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Represents an HTTP response message. More...
#include <http_types.h>

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. | |
| auto | set_cookie (const std::string &name, const std::string &value, const std::string &path="/", int max_age=-1, bool http_only=true, bool secure=false, const std::string &same_site="") -> void |
| Set a cookie in the response. | |
Public Attributes | |
| int | status_code = 200 |
| std::string | status_message = "OK" |
| http_version | version = http_version::HTTP_1_1 |
| std::map< std::string, std::string > | headers |
| std::vector< uint8_t > | body |
| std::vector< cookie > | set_cookies |
| bool | use_chunked_encoding = false |
Represents an HTTP response message.
Definition at line 161 of file http_types.h.
| auto kcenon::network::internal::http_response::get_body_string | ( | ) | const -> std::string |
Get body as string.
Definition at line 102 of file http_types.cpp.
References body.
| auto kcenon::network::internal::http_response::get_header | ( | const std::string & | name | ) | const -> std::optional<std::string> |
Get the value of a header (case-insensitive)
| name | Header name |
Definition at line 69 of file http_types.cpp.
Referenced by kcenon::network::core::http_server::handle_request(), and kcenon::network::core::http_server::process_http_request().

| auto kcenon::network::internal::http_response::set_body_string | ( | const std::string & | content | ) | -> void |
Set body from string.
| content | Body content as UTF-8 string |
Definition at line 107 of file http_types.cpp.
Referenced by kcenon::network::internal::http_error_response::build_html_error(), and kcenon::network::internal::http_error_response::build_json_error().

| auto kcenon::network::internal::http_response::set_cookie | ( | const std::string & | name, |
| const std::string & | value, | ||
| const std::string & | path = "/", | ||
| int | max_age = -1, | ||
| bool | http_only = true, | ||
| bool | secure = false, | ||
| const std::string & | same_site = "" ) -> void |
Set a cookie in the response.
| name | Cookie name |
| value | Cookie value |
| path | Cookie path (default: "/") |
| max_age | Maximum age in seconds (default: -1 for session cookie) |
| http_only | HttpOnly flag (default: true) |
| secure | Secure flag (default: false) |
| same_site | SameSite attribute (default: empty) |
Definition at line 267 of file http_types.cpp.
References kcenon::network::internal::cookie::http_only, kcenon::network::internal::cookie::max_age, kcenon::network::internal::cookie::name, kcenon::network::internal::cookie::path, kcenon::network::internal::cookie::same_site, kcenon::network::internal::cookie::secure, and kcenon::network::internal::cookie::value.
| auto kcenon::network::internal::http_response::set_header | ( | const std::string & | name, |
| const std::string & | value ) -> void |
Set a header value.
| name | Header name |
| value | Header value |
Definition at line 82 of file http_types.cpp.
Referenced by kcenon::network::internal::http_error_response::build_html_error(), kcenon::network::internal::http_error_response::build_json_error(), kcenon::network::core::http_server::handle_request(), kcenon::network::core::http_server::process_http_request(), and kcenon::network::internal::adapters::http_server_adapter::setup_internal_routes().

| std::vector<uint8_t> kcenon::network::internal::http_response::body |
| std::map<std::string, std::string> kcenon::network::internal::http_response::headers |
Definition at line 166 of file http_types.h.
| std::vector<cookie> kcenon::network::internal::http_response::set_cookies |
Definition at line 168 of file http_types.h.
| int kcenon::network::internal::http_response::status_code = 200 |
Definition at line 163 of file http_types.h.
Referenced by kcenon::network::internal::http_error_response::build_html_error(), kcenon::network::internal::http_error_response::build_json_error(), kcenon::network::internal::http_parser::parse_status_line(), and kcenon::network::internal::adapters::http_server_adapter::setup_internal_routes().
| std::string kcenon::network::internal::http_response::status_message = "OK" |
Definition at line 164 of file http_types.h.
Referenced by kcenon::network::internal::http_error_response::build_html_error(), kcenon::network::internal::http_error_response::build_json_error(), and kcenon::network::internal::http_parser::parse_status_line().
| bool kcenon::network::internal::http_response::use_chunked_encoding = false |
Definition at line 169 of file http_types.h.
| http_version kcenon::network::internal::http_response::version = http_version::HTTP_1_1 |
Definition at line 165 of file http_types.h.
Referenced by kcenon::network::internal::http_parser::parse_status_line().