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

Namespaces

namespace  adapters
 

Classes

struct  cookie
 Represents an HTTP cookie. More...
 
class  dtls_socket
 A wrapper around ASIO UDP socket with OpenSSL DTLS encryption. More...
 
struct  http_error
 Structured HTTP error information. More...
 
class  http_error_response
 Builder for HTTP error responses. More...
 
class  http_parser
 Parser and serializer for HTTP messages (requests and responses) More...
 
struct  http_request
 Represents an HTTP request message. More...
 
struct  http_response
 Represents an HTTP response message. More...
 
struct  multipart_file
 Represents a file uploaded via multipart/form-data. More...
 
struct  parse_error
 Detailed HTTP parsing error information. More...
 
class  quic_socket
 A QUIC socket that wraps UDP and integrates QUIC packet protection. More...
 
class  secure_tcp_socket
 A lightweight wrapper around asio::ssl::stream<asio::ip::tcp::socket>, enabling asynchronous TLS/SSL encrypted read and write operations. More...
 
struct  socket_config
 Configuration for TCP socket backpressure control. More...
 
struct  socket_metrics
 Runtime metrics for socket monitoring. More...
 
class  tcp_socket
 A lightweight wrapper around asio::ip::tcp::socket, enabling asynchronous read and write operations. More...
 
struct  tls_config
 Configuration for TLS/SSL connections. More...
 
class  udp_socket
 A lightweight wrapper around asio::ip::udp::socket, enabling asynchronous datagram operations. More...
 
class  websocket_frame
 Provides WebSocket frame encoding and decoding functionality. More...
 
class  websocket_handshake
 Implements WebSocket HTTP/1.1 upgrade handshake (RFC 6455). More...
 
class  websocket_protocol
 WebSocket protocol handler for message processing. More...
 
class  websocket_socket
 WebSocket framing layer built on top of tcp_socket. More...
 
struct  ws_frame_header
 Represents a decoded WebSocket frame header. More...
 
struct  ws_handshake_result
 Result of a WebSocket handshake operation. More...
 
struct  ws_message
 Represents a complete WebSocket message. More...
 

Typedefs

template<typename T >
using Result = ::kcenon::network::Result<T>
 
using VoidResult = ::kcenon::network::VoidResult
 
using error_info = ::kcenon::network::error_info
 

Enumerations

enum class  http_error_code {
  bad_request = 400 , unauthorized = 401 , payment_required = 402 , forbidden = 403 ,
  not_found = 404 , method_not_allowed = 405 , not_acceptable = 406 , proxy_authentication_required = 407 ,
  request_timeout = 408 , conflict = 409 , gone = 410 , length_required = 411 ,
  precondition_failed = 412 , payload_too_large = 413 , uri_too_long = 414 , unsupported_media_type = 415 ,
  range_not_satisfiable = 416 , expectation_failed = 417 , im_a_teapot = 418 , misdirected_request = 421 ,
  unprocessable_entity = 422 , locked = 423 , failed_dependency = 424 , too_early = 425 ,
  upgrade_required = 426 , precondition_required = 428 , too_many_requests = 429 , request_header_fields_too_large = 431 ,
  unavailable_for_legal_reasons = 451 , internal_server_error = 500 , not_implemented = 501 , bad_gateway = 502 ,
  service_unavailable = 503 , gateway_timeout = 504 , http_version_not_supported = 505 , variant_also_negotiates = 506 ,
  insufficient_storage = 507 , loop_detected = 508 , not_extended = 510 , network_authentication_required = 511
}
 Standard HTTP error codes (RFC 7231) More...
 
enum class  parse_error_type {
  invalid_method , invalid_uri , invalid_version , invalid_header ,
  incomplete_headers , incomplete_body , body_too_large , header_too_large ,
  malformed_request
}
 Types of HTTP parsing errors. More...
 
enum class  http_method {
  HTTP_GET , HTTP_POST , HTTP_PUT , HTTP_DELETE ,
  HTTP_HEAD , HTTP_OPTIONS , HTTP_PATCH , HTTP_CONNECT ,
  HTTP_TRACE
}
 HTTP request methods (verbs) More...
 
enum class  http_version { HTTP_1_0 , HTTP_1_1 , HTTP_2_0 }
 HTTP protocol version. More...
 
enum class  quic_role : uint8_t { client = 0 , server = 1 }
 Role of the QUIC endpoint (client or server) More...
 
enum class  quic_connection_state : uint8_t {
  idle = 0 , handshake_start = 1 , handshake = 2 , connected = 3 ,
  closing = 4 , draining = 5 , closed = 6
}
 QUIC connection state machine states. More...
 
enum class  data_mode : std::uint8_t { packet_mode = 1 , file_mode = 2 , binary_mode = 3 }
 Represents a simple enumeration for differentiating data transmission modes. More...
 
enum class  tls_version : std::uint8_t { tls_1_0 = 10 , tls_1_1 = 11 , tls_1_2 = 12 , tls_1_3 = 13 }
 TLS protocol versions. More...
 
enum class  certificate_verification : std::uint8_t { none = 0 , verify_peer = 1 , verify_fail_if_no_peer_cert = 2 }
 Certificate verification modes. More...
 
enum class  ws_opcode : uint8_t {
  continuation = 0x0 , text = 0x1 , binary = 0x2 , close = 0x8 ,
  ping = 0x9 , pong = 0xA
}
 WebSocket frame operation codes as defined in RFC 6455. More...
 
enum class  ws_message_type { text , binary }
 Type of WebSocket message. More...
 
enum class  ws_close_code : uint16_t {
  normal = 1000 , going_away = 1001 , protocol_error = 1002 , unsupported_data = 1003 ,
  invalid_frame = 1007 , policy_violation = 1008 , message_too_big = 1009 , internal_error = 1011
}
 WebSocket close status codes (RFC 6455 Section 7.4). More...
 
enum class  ws_state { connecting , open , closing , closed }
 WebSocket connection state (RFC 6455 Section 7). More...
 

Functions

auto get_error_status_text (http_error_code code) -> std::string_view
 Get status text for HTTP error code.
 
auto http_method_to_string (http_method method) -> std::string
 Convert HTTP method enum to string.
 
auto string_to_http_method (const std::string &method_str) -> ::kcenon::network::internal::Result< http_method >
 Convert string to HTTP method enum.
 
auto http_version_to_string (http_version version) -> std::string
 Convert HTTP version enum to string.
 
auto string_to_http_version (const std::string &version_str) -> ::kcenon::network::internal::Result< http_version >
 Convert string to HTTP version enum.
 
auto get_status_message (int status_code) -> std::string
 Get HTTP status message for a status code.
 
static auto escape_json_string (const std::string &input) -> std::string
 
static auto escape_html_string (const std::string &input) -> std::string
 
const char * openssl_version_string () noexcept
 Get OpenSSL version string.
 
std::string get_openssl_error () noexcept
 Get last OpenSSL error as string.
 
void clear_openssl_errors () noexcept
 Clear all OpenSSL errors from the thread's error queue.
 

Variables

constexpr std::size_t default_buffer_size = 4096
 
constexpr std::size_t default_timeout_ms = 5000
 
constexpr std::string_view default_client_id = "default_client"
 
constexpr std::string_view default_server_id = "default_server"
 
constexpr std::string_view default_tls_cipher_list
 

Typedef Documentation

◆ error_info

◆ Result

Definition at line 169 of file result_types.h.

◆ VoidResult

Enumeration Type Documentation

◆ certificate_verification

enum class kcenon::network::internal::certificate_verification : std::uint8_t
strong

Certificate verification modes.

Enumerator
none 

No verification (insecure, testing only)

verify_peer 

Verify peer certificate

verify_fail_if_no_peer_cert 

Fail if peer doesn't provide cert

Definition at line 124 of file common_defs.h.

◆ data_mode

enum class kcenon::network::internal::data_mode : std::uint8_t
strong

Represents a simple enumeration for differentiating data transmission modes.

A higher-level code might use these to switch between packet-based, file-based, or binary data logic. They are optional stubs and can be extended as needed.

Enumerator
packet_mode 

Regular messaging/packet mode.

file_mode 

File transfer mode.

binary_mode 

Raw binary data mode.

Definition at line 100 of file common_defs.h.

◆ http_error_code

Standard HTTP error codes (RFC 7231)

Enumerator
bad_request 
unauthorized 
payment_required 
forbidden 
not_found 
method_not_allowed 
not_acceptable 
proxy_authentication_required 
request_timeout 
conflict 
gone 
length_required 
precondition_failed 
payload_too_large 
uri_too_long 
unsupported_media_type 
range_not_satisfiable 
expectation_failed 
im_a_teapot 
misdirected_request 
unprocessable_entity 
locked 
failed_dependency 
too_early 
upgrade_required 
precondition_required 
too_many_requests 
request_header_fields_too_large 
unavailable_for_legal_reasons 
internal_server_error 
not_implemented 
bad_gateway 
service_unavailable 
gateway_timeout 
http_version_not_supported 
variant_also_negotiates 
insufficient_storage 
loop_detected 
not_extended 
network_authentication_required 

Definition at line 19 of file http_error.h.

20 {
21 // Client Errors (4xx)
22 bad_request = 400,
23 unauthorized = 401,
24 payment_required = 402,
25 forbidden = 403,
26 not_found = 404,
28 not_acceptable = 406,
30 request_timeout = 408,
31 conflict = 409,
32 gone = 410,
33 length_required = 411,
36 uri_too_long = 414,
40 im_a_teapot = 418,
43 locked = 423,
45 too_early = 425,
46 upgrade_required = 426,
51
52 // Server Errors (5xx)
54 not_implemented = 501,
55 bad_gateway = 502,
57 gateway_timeout = 504,
61 loop_detected = 508,
62 not_extended = 510,
64 };

◆ http_method

HTTP request methods (verbs)

Note: Uses HTTP_ prefix to avoid conflicts with Windows macros (DELETE)

Enumerator
HTTP_GET 
HTTP_POST 
HTTP_PUT 
HTTP_DELETE 
HTTP_HEAD 
HTTP_OPTIONS 
HTTP_PATCH 
HTTP_CONNECT 
HTTP_TRACE 

Definition at line 23 of file http_types.h.

◆ http_version

HTTP protocol version.

Enumerator
HTTP_1_0 
HTTP_1_1 
HTTP_2_0 

Definition at line 40 of file http_types.h.

◆ parse_error_type

◆ quic_connection_state

QUIC connection state machine states.

Enumerator
idle 

Not yet started.

handshake_start 

Initiating handshake.

handshake 

Handshake in progress.

connected 

Connection established.

closing 

Closing connection.

draining 

Draining period before close.

closed 

Connection closed.

Definition at line 40 of file quic_socket.h.

41 {
42 idle = 0,
43 handshake_start = 1,
44 handshake = 2,
45 connected = 3,
46 closing = 4,
47 draining = 5,
48 closed = 6
49 };
@ closing
CONNECTION_CLOSE sent, waiting for timeout.
@ draining
CONNECTION_CLOSE received, draining period.

◆ quic_role

enum class kcenon::network::internal::quic_role : uint8_t
strong

Role of the QUIC endpoint (client or server)

Enumerator
client 
server 

Definition at line 30 of file quic_socket.h.

31 {
32 client = 0,
33 server = 1
34 };

◆ tls_version

enum class kcenon::network::internal::tls_version : std::uint8_t
strong

TLS protocol versions.

Specifies which TLS version to use for secure connections. Modern applications should use TLS 1.2 or 1.3.

Enumerator
tls_1_0 

TLS 1.0 (deprecated, insecure)

tls_1_1 

TLS 1.1 (deprecated, insecure)

tls_1_2 

TLS 1.2 (secure, widely supported)

tls_1_3 

TLS 1.3 (most secure, recommended)

Definition at line 113 of file common_defs.h.

◆ ws_close_code

enum class kcenon::network::internal::ws_close_code : uint16_t
strong

WebSocket close status codes (RFC 6455 Section 7.4).

These codes indicate the reason for closing the WebSocket connection.

Enumerator
normal 

Normal closure.

going_away 

Endpoint is going away.

protocol_error 

Protocol error.

unsupported_data 

Unsupported data type.

invalid_frame 

Invalid frame payload data.

policy_violation 

Policy violation.

message_too_big 

Message too large.

internal_error 

Internal server error.

Definition at line 60 of file websocket_protocol.h.

61 {
62 normal = 1000,
63 going_away = 1001,
64 protocol_error = 1002,
65 unsupported_data = 1003,
66 invalid_frame = 1007,
67 policy_violation = 1008,
68 message_too_big = 1009,
69 internal_error = 1011
70 };
@ going_away
Endpoint is going away.
@ unsupported_data
Unsupported data type.
@ invalid_frame
Invalid frame payload data.

◆ ws_message_type

Type of WebSocket message.

WebSocket supports two types of data messages: text (UTF-8) and binary.

Enumerator
text 

Text message (UTF-8 encoded)

binary 

Binary message.

Definition at line 23 of file websocket_protocol.h.

24 {
25 text,
26 binary
27 };
@ text
Text frame (UTF-8 encoded)

◆ ws_opcode

enum class kcenon::network::internal::ws_opcode : uint8_t
strong

WebSocket frame operation codes as defined in RFC 6455.

These opcodes indicate the type of data contained in a WebSocket frame. The values are from the WebSocket protocol specification.

Enumerator
continuation 

Continuation frame.

text 

Text frame (UTF-8 encoded)

binary 

Binary frame.

close 

Connection close frame.

ping 

Ping frame.

pong 

Pong frame.

Definition at line 21 of file websocket_frame.h.

22 {
23 continuation = 0x0,
24 text = 0x1,
25 binary = 0x2,
26 close = 0x8,
27 ping = 0x9,
28 pong = 0xA
29 };
@ close
Connection close frame.

◆ ws_state

WebSocket connection state (RFC 6455 Section 7).

Tracks the lifecycle of a WebSocket connection from initial connection through the closing handshake.

Enumerator
connecting 

Handshake in progress.

open 

Connection established and ready.

closing 

Close handshake initiated.

closed 

Connection closed.

Definition at line 32 of file websocket_socket.h.

33 {
34 connecting,
35 open,
36 closing,
37 closed
38 };

Function Documentation

◆ clear_openssl_errors()

void kcenon::network::internal::clear_openssl_errors ( )
inlinenoexcept

Clear all OpenSSL errors from the thread's error queue.

This should be called before operations where you want to check for fresh errors.

Definition at line 115 of file openssl_compat.h.

116{
117 ERR_clear_error();
118}

◆ escape_html_string()

static auto kcenon::network::internal::escape_html_string ( const std::string & input) -> std::string
static

Definition at line 151 of file http_error.cpp.

152{
153 std::ostringstream oss;
154 for (char c : input)
155 {
156 switch (c)
157 {
158 case '&':
159 oss << "&amp;";
160 break;
161 case '<':
162 oss << "&lt;";
163 break;
164 case '>':
165 oss << "&gt;";
166 break;
167 case '"':
168 oss << "&quot;";
169 break;
170 case '\'':
171 oss << "&#39;";
172 break;
173 default:
174 oss << c;
175 break;
176 }
177 }
178 return oss.str();
179}

Referenced by kcenon::network::internal::http_error_response::build_html_error().

Here is the caller graph for this function:

◆ escape_json_string()

static auto kcenon::network::internal::escape_json_string ( const std::string & input) -> std::string
static

Definition at line 106 of file http_error.cpp.

107{
108 std::ostringstream oss;
109 for (char c : input)
110 {
111 switch (c)
112 {
113 case '"':
114 oss << "\\\"";
115 break;
116 case '\\':
117 oss << "\\\\";
118 break;
119 case '\b':
120 oss << "\\b";
121 break;
122 case '\f':
123 oss << "\\f";
124 break;
125 case '\n':
126 oss << "\\n";
127 break;
128 case '\r':
129 oss << "\\r";
130 break;
131 case '\t':
132 oss << "\\t";
133 break;
134 default:
135 if (static_cast<unsigned char>(c) < 0x20)
136 {
137 oss << "\\u" << std::hex << std::setw(4) << std::setfill('0')
138 << static_cast<int>(c);
139 }
140 else
141 {
142 oss << c;
143 }
144 break;
145 }
146 }
147 return oss.str();
148}

Referenced by kcenon::network::internal::http_error_response::build_json_error().

Here is the caller graph for this function:

◆ get_error_status_text()

auto kcenon::network::internal::get_error_status_text ( http_error_code code) -> std::string_view

Get status text for HTTP error code.

Parameters
codeHTTP error code
Returns
Status text (e.g., "Not Found")

Definition at line 13 of file http_error.cpp.

14{
15 switch (code)
16 {
17 // Client Errors (4xx)
18 case http_error_code::bad_request:
19 return "Bad Request";
20 case http_error_code::unauthorized:
21 return "Unauthorized";
22 case http_error_code::payment_required:
23 return "Payment Required";
24 case http_error_code::forbidden:
25 return "Forbidden";
26 case http_error_code::not_found:
27 return "Not Found";
28 case http_error_code::method_not_allowed:
29 return "Method Not Allowed";
30 case http_error_code::not_acceptable:
31 return "Not Acceptable";
32 case http_error_code::proxy_authentication_required:
33 return "Proxy Authentication Required";
34 case http_error_code::request_timeout:
35 return "Request Timeout";
36 case http_error_code::conflict:
37 return "Conflict";
38 case http_error_code::gone:
39 return "Gone";
40 case http_error_code::length_required:
41 return "Length Required";
42 case http_error_code::precondition_failed:
43 return "Precondition Failed";
44 case http_error_code::payload_too_large:
45 return "Payload Too Large";
46 case http_error_code::uri_too_long:
47 return "URI Too Long";
48 case http_error_code::unsupported_media_type:
49 return "Unsupported Media Type";
50 case http_error_code::range_not_satisfiable:
51 return "Range Not Satisfiable";
52 case http_error_code::expectation_failed:
53 return "Expectation Failed";
54 case http_error_code::im_a_teapot:
55 return "I'm a teapot";
56 case http_error_code::misdirected_request:
57 return "Misdirected Request";
58 case http_error_code::unprocessable_entity:
59 return "Unprocessable Entity";
60 case http_error_code::locked:
61 return "Locked";
62 case http_error_code::failed_dependency:
63 return "Failed Dependency";
64 case http_error_code::too_early:
65 return "Too Early";
66 case http_error_code::upgrade_required:
67 return "Upgrade Required";
68 case http_error_code::precondition_required:
69 return "Precondition Required";
70 case http_error_code::too_many_requests:
71 return "Too Many Requests";
72 case http_error_code::request_header_fields_too_large:
73 return "Request Header Fields Too Large";
74 case http_error_code::unavailable_for_legal_reasons:
75 return "Unavailable For Legal Reasons";
76
77 // Server Errors (5xx)
78 case http_error_code::internal_server_error:
79 return "Internal Server Error";
80 case http_error_code::not_implemented:
81 return "Not Implemented";
82 case http_error_code::bad_gateway:
83 return "Bad Gateway";
84 case http_error_code::service_unavailable:
85 return "Service Unavailable";
86 case http_error_code::gateway_timeout:
87 return "Gateway Timeout";
88 case http_error_code::http_version_not_supported:
89 return "HTTP Version Not Supported";
90 case http_error_code::variant_also_negotiates:
91 return "Variant Also Negotiates";
92 case http_error_code::insufficient_storage:
93 return "Insufficient Storage";
94 case http_error_code::loop_detected:
95 return "Loop Detected";
96 case http_error_code::not_extended:
97 return "Not Extended";
98 case http_error_code::network_authentication_required:
99 return "Network Authentication Required";
100 default:
101 return "Unknown Error";
102 }
103}

References bad_gateway, bad_request, conflict, expectation_failed, failed_dependency, forbidden, gateway_timeout, gone, http_version_not_supported, im_a_teapot, insufficient_storage, internal_server_error, length_required, locked, loop_detected, method_not_allowed, misdirected_request, network_authentication_required, not_acceptable, not_extended, not_found, not_implemented, payload_too_large, payment_required, precondition_failed, precondition_required, proxy_authentication_required, range_not_satisfiable, request_header_fields_too_large, request_timeout, service_unavailable, too_early, too_many_requests, unauthorized, unavailable_for_legal_reasons, unprocessable_entity, unsupported_media_type, upgrade_required, uri_too_long, and variant_also_negotiates.

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_error_response::make_error().

Here is the caller graph for this function:

◆ get_openssl_error()

std::string kcenon::network::internal::get_openssl_error ( )
inlinenoexcept

Get last OpenSSL error as string.

Returns
Human-readable error message

This function works consistently across OpenSSL versions.

Definition at line 97 of file openssl_compat.h.

98{
99 unsigned long err = ERR_get_error();
100 if (err == 0)
101 {
102 return "No OpenSSL error";
103 }
104 char buf[256];
105 ERR_error_string_n(err, buf, sizeof(buf));
106 return std::string(buf);
107}

◆ get_status_message()

auto kcenon::network::internal::get_status_message ( int status_code) -> std::string

Get HTTP status message for a status code.

Parameters
status_codeHTTP status code
Returns
Status message (e.g., "OK" for 200)

Definition at line 177 of file http_types.cpp.

178 {
179 switch (status_code)
180 {
181 // 1xx Informational
182 case 100: return "Continue";
183 case 101: return "Switching Protocols";
184
185 // 2xx Success
186 case 200: return "OK";
187 case 201: return "Created";
188 case 202: return "Accepted";
189 case 203: return "Non-Authoritative Information";
190 case 204: return "No Content";
191 case 205: return "Reset Content";
192 case 206: return "Partial Content";
193
194 // 3xx Redirection
195 case 300: return "Multiple Choices";
196 case 301: return "Moved Permanently";
197 case 302: return "Found";
198 case 303: return "See Other";
199 case 304: return "Not Modified";
200 case 307: return "Temporary Redirect";
201 case 308: return "Permanent Redirect";
202
203 // 4xx Client Error
204 case 400: return "Bad Request";
205 case 401: return "Unauthorized";
206 case 402: return "Payment Required";
207 case 403: return "Forbidden";
208 case 404: return "Not Found";
209 case 405: return "Method Not Allowed";
210 case 406: return "Not Acceptable";
211 case 407: return "Proxy Authentication Required";
212 case 408: return "Request Timeout";
213 case 409: return "Conflict";
214 case 410: return "Gone";
215 case 411: return "Length Required";
216 case 412: return "Precondition Failed";
217 case 413: return "Payload Too Large";
218 case 414: return "URI Too Long";
219 case 415: return "Unsupported Media Type";
220 case 416: return "Range Not Satisfiable";
221 case 417: return "Expectation Failed";
222 case 429: return "Too Many Requests";
223
224 // 5xx Server Error
225 case 500: return "Internal Server Error";
226 case 501: return "Not Implemented";
227 case 502: return "Bad Gateway";
228 case 503: return "Service Unavailable";
229 case 504: return "Gateway Timeout";
230 case 505: return "HTTP Version Not Supported";
231
232 default: return "Unknown";
233 }
234 }

Referenced by kcenon::network::internal::http_parser::parse_status_line().

Here is the caller graph for this function:

◆ http_method_to_string()

auto kcenon::network::internal::http_method_to_string ( http_method method) -> std::string

Convert HTTP method enum to string.

Parameters
methodHTTP method enum value
Returns
Method as string (e.g., "GET", "POST")

Definition at line 114 of file http_types.cpp.

115 {
116 switch (method)
117 {
118 case http_method::HTTP_GET: return "GET";
119 case http_method::HTTP_POST: return "POST";
120 case http_method::HTTP_PUT: return "PUT";
121 case http_method::HTTP_DELETE: return "DELETE";
122 case http_method::HTTP_HEAD: return "HEAD";
123 case http_method::HTTP_OPTIONS: return "OPTIONS";
124 case http_method::HTTP_PATCH: return "PATCH";
125 case http_method::HTTP_CONNECT: return "CONNECT";
126 case http_method::HTTP_TRACE: return "TRACE";
127 default: return "GET";
128 }
129 }

References HTTP_CONNECT, HTTP_DELETE, HTTP_GET, HTTP_HEAD, HTTP_OPTIONS, HTTP_PATCH, HTTP_POST, HTTP_PUT, and HTTP_TRACE.

Referenced by kcenon::network::internal::http_parser::serialize_request().

Here is the caller graph for this function:

◆ http_version_to_string()

auto kcenon::network::internal::http_version_to_string ( http_version version) -> std::string

Convert HTTP version enum to string.

Parameters
versionHTTP version enum value
Returns
Version as string (e.g., "HTTP/1.1")

Definition at line 153 of file http_types.cpp.

154 {
155 switch (version)
156 {
157 case http_version::HTTP_1_0: return "HTTP/1.0";
158 case http_version::HTTP_1_1: return "HTTP/1.1";
159 case http_version::HTTP_2_0: return "HTTP/2.0";
160 default: return "HTTP/1.1";
161 }
162 }

References HTTP_1_0, HTTP_1_1, HTTP_2_0, and kcenon::network::version().

Referenced by kcenon::network::internal::http_parser::serialize_chunked_response(), kcenon::network::internal::http_parser::serialize_request(), and kcenon::network::internal::http_parser::serialize_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openssl_version_string()

const char * kcenon::network::internal::openssl_version_string ( )
inlinenoexcept

Get OpenSSL version string.

Returns
Human-readable OpenSSL version string

Definition at line 86 of file openssl_compat.h.

87{
88 return OpenSSL_version(OPENSSL_VERSION);
89}

◆ string_to_http_method()

auto kcenon::network::internal::string_to_http_method ( const std::string & method_str) -> ::kcenon::network::internal::Result<http_method>

Convert string to HTTP method enum.

Parameters
method_strMethod string (e.g., "GET", "POST")
Returns
Result containing HTTP method enum value, or error if invalid

Possible errors:

  • invalid_argument: Unknown HTTP method string

Definition at line 131 of file http_types.cpp.

132 {
133 auto upper_method = method_str;
134 std::transform(upper_method.begin(), upper_method.end(), upper_method.begin(),
135 [](unsigned char c) { return std::toupper(c); });
136
137 if (upper_method == "GET") return ::kcenon::network::ok(http_method::HTTP_GET);
138 if (upper_method == "POST") return ::kcenon::network::ok(http_method::HTTP_POST);
139 if (upper_method == "PUT") return ::kcenon::network::ok(http_method::HTTP_PUT);
140 if (upper_method == "DELETE") return ::kcenon::network::ok(http_method::HTTP_DELETE);
141 if (upper_method == "HEAD") return ::kcenon::network::ok(http_method::HTTP_HEAD);
142 if (upper_method == "OPTIONS") return ::kcenon::network::ok(http_method::HTTP_OPTIONS);
143 if (upper_method == "PATCH") return ::kcenon::network::ok(http_method::HTTP_PATCH);
144 if (upper_method == "CONNECT") return ::kcenon::network::ok(http_method::HTTP_CONNECT);
145 if (upper_method == "TRACE") return ::kcenon::network::ok(http_method::HTTP_TRACE);
146
147 return ::kcenon::network::error<http_method>(
149 "Unknown HTTP method: " + method_str,
150 "http_types");
151 }

References HTTP_CONNECT, HTTP_DELETE, HTTP_GET, HTTP_HEAD, HTTP_OPTIONS, HTTP_PATCH, HTTP_POST, HTTP_PUT, HTTP_TRACE, and kcenon::network::error_codes::common_errors::invalid_argument.

Referenced by kcenon::network::internal::http_parser::parse_request_line().

Here is the caller graph for this function:

◆ string_to_http_version()

auto kcenon::network::internal::string_to_http_version ( const std::string & version_str) -> ::kcenon::network::internal::Result<http_version>

Convert string to HTTP version enum.

Parameters
version_strVersion string (e.g., "HTTP/1.1")
Returns
Result containing HTTP version enum value, or error if invalid

Possible errors:

  • invalid_argument: Unknown HTTP version string

Definition at line 164 of file http_types.cpp.

165 {
166 if (version_str == "HTTP/1.0") return ::kcenon::network::ok(http_version::HTTP_1_0);
167 if (version_str == "HTTP/1.1") return ::kcenon::network::ok(http_version::HTTP_1_1);
168 if (version_str == "HTTP/2.0") return ::kcenon::network::ok(http_version::HTTP_2_0);
169 if (version_str == "HTTP/2") return ::kcenon::network::ok(http_version::HTTP_2_0);
170
171 return ::kcenon::network::error<http_version>(
173 "Unknown HTTP version: " + version_str,
174 "http_types");
175 }

References HTTP_1_0, HTTP_1_1, HTTP_2_0, and kcenon::network::error_codes::common_errors::invalid_argument.

Referenced by kcenon::network::internal::http_parser::parse_request_line(), and kcenon::network::internal::http_parser::parse_status_line().

Here is the caller graph for this function:

Variable Documentation

◆ default_buffer_size

std::size_t kcenon::network::internal::default_buffer_size = 4096
inlineconstexpr

Definition at line 280 of file common_defs.h.

◆ default_client_id

std::string_view kcenon::network::internal::default_client_id = "default_client"
inlineconstexpr

Definition at line 282 of file common_defs.h.

◆ default_server_id

std::string_view kcenon::network::internal::default_server_id = "default_server"
inlineconstexpr

Definition at line 283 of file common_defs.h.

◆ default_timeout_ms

std::size_t kcenon::network::internal::default_timeout_ms = 5000
inlineconstexpr

Definition at line 281 of file common_defs.h.

◆ default_tls_cipher_list

std::string_view kcenon::network::internal::default_tls_cipher_list
inlineconstexpr
Initial value:
=
"ECDHE-RSA-AES256-GCM-SHA384:"
"ECDHE-RSA-AES128-GCM-SHA256:"
"ECDHE-RSA-CHACHA20-POLY1305"

Definition at line 286 of file common_defs.h.