|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Parser and serializer for HTTP messages (requests and responses) More...
#include <http_parser.h>

Static Public Member Functions | |
| static auto | parse_request (const std::vector< uint8_t > &data) -> Result< http_request > |
| Parse HTTP request from raw bytes. | |
| static auto | parse_request (std::string_view data) -> Result< http_request > |
| Parse HTTP request from string view. | |
| static auto | parse_response (const std::vector< uint8_t > &data) -> Result< http_response > |
| Parse HTTP response from raw bytes. | |
| static auto | parse_response (std::string_view data) -> Result< http_response > |
| Parse HTTP response from string view. | |
| static auto | serialize_request (const http_request &request) -> std::vector< uint8_t > |
| Serialize HTTP request to raw bytes. | |
| static auto | serialize_response (const http_response &response) -> std::vector< uint8_t > |
| Serialize HTTP response to raw bytes. | |
| static auto | url_encode (const std::string &value) -> std::string |
| URL encode a string. | |
| static auto | url_decode (const std::string &value) -> std::string |
| URL decode a string. | |
| static auto | parse_query_string (const std::string &query_string) -> std::map< std::string, std::string > |
| Parse query string into key-value pairs. | |
| static auto | build_query_string (const std::map< std::string, std::string > ¶ms) -> std::string |
| Build query string from key-value pairs. | |
| static auto | parse_cookies (http_request &request) -> void |
| Parse cookies from Cookie header. | |
| static auto | parse_multipart_form_data (http_request &request) -> VoidResult |
| Parse multipart/form-data from request body. | |
Static Private Member Functions | |
| static auto | parse_request_line (std::string_view line) -> Result< http_request > |
| static auto | parse_status_line (std::string_view line) -> Result< http_response > |
| static auto | parse_headers (std::string_view headers_section, std::map< std::string, std::string > &headers) -> bool |
| static auto | trim (std::string_view str) -> std::string_view |
| static auto | split_line (std::string_view data) -> std::pair< std::string_view, std::string_view > |
| static auto | serialize_chunked_response (const http_response &response) -> std::vector< uint8_t > |
Parser and serializer for HTTP messages (requests and responses)
Definition at line 49 of file http_parser.h.
|
static |
Build query string from key-value pairs.
| params | Map of query parameters |
Definition at line 522 of file http_parser.cpp.
|
static |
Parse cookies from Cookie header.
| request | HTTP request to parse cookies into |
Parses the Cookie header (if present) and populates request.cookies Cookie format: "name1=value1; name2=value2"
Definition at line 546 of file http_parser.cpp.
|
staticprivate |
Definition at line 149 of file http_parser.cpp.
|
static |
Parse multipart/form-data from request body.
| request | HTTP request to parse multipart data from |
Parses multipart/form-data body and populates request.form_data and request.files Requires Content-Type header with boundary parameter
Definition at line 604 of file http_parser.cpp.
References kcenon::network::internal::multipart_file::content, kcenon::network::internal::multipart_file::content_type, kcenon::network::protocols::quic::error, kcenon::network::internal::multipart_file::field_name, kcenon::network::internal::multipart_file::filename, and kcenon::network::ok().

|
static |
Parse query string into key-value pairs.
| query_string | Query string (e.g., "key1=value1&key2=value2") |
Definition at line 496 of file http_parser.cpp.
Referenced by kcenon::network::core::http_url::parse().

|
static |
Parse HTTP request from raw bytes.
| data | Raw HTTP request data |
Parses the following format:
Definition at line 179 of file http_parser.cpp.
Referenced by kcenon::network::core::http_server::handle_request(), and kcenon::network::core::http_server::start().

|
static |
Parse HTTP request from string view.
| data | String view of HTTP request |
Definition at line 185 of file http_parser.cpp.
References kcenon::network::protocols::quic::error, and kcenon::network::ok().

|
staticprivate |
Definition at line 44 of file http_parser.cpp.
References kcenon::network::protocols::quic::error, kcenon::network::internal::http_request::method, kcenon::network::ok(), kcenon::network::internal::http_request::query_params, kcenon::network::internal::string_to_http_method(), kcenon::network::internal::string_to_http_version(), kcenon::network::internal::http_request::uri, and kcenon::network::internal::http_request::version.

|
static |
Parse HTTP response from raw bytes.
| data | Raw HTTP response data |
Parses the following format:
Definition at line 235 of file http_parser.cpp.
Referenced by kcenon::network::core::http_client::request().

|
static |
Parse HTTP response from string view.
| data | String view of HTTP response |
Definition at line 241 of file http_parser.cpp.
References kcenon::network::protocols::quic::error, and kcenon::network::ok().

|
staticprivate |
Definition at line 96 of file http_parser.cpp.
References kcenon::network::protocols::quic::error, kcenon::network::internal::get_status_message(), kcenon::network::ok(), kcenon::network::internal::http_response::status_code, kcenon::network::internal::http_response::status_message, kcenon::network::internal::string_to_http_version(), and kcenon::network::internal::http_response::version.

|
staticprivate |
Definition at line 366 of file http_parser.cpp.
References kcenon::network::internal::http_version_to_string(), NETWORK_LOG_DEBUG, and kcenon::network::internal::cookie::to_header_value().

|
static |
Serialize HTTP request to raw bytes.
| request | HTTP request to serialize |
Definition at line 291 of file http_parser.cpp.
References kcenon::network::internal::http_method_to_string(), and kcenon::network::internal::http_version_to_string().
Referenced by kcenon::network::core::http_client::request().


|
static |
Serialize HTTP response to raw bytes.
| response | HTTP response to serialize |
Definition at line 326 of file http_parser.cpp.
References kcenon::network::internal::HTTP_1_1, kcenon::network::internal::http_version_to_string(), and kcenon::network::internal::cookie::to_header_value().
Referenced by kcenon::network::core::http_server::handle_request(), and kcenon::network::core::http_server::start().


|
staticprivate |
|
staticprivate |
Definition at line 22 of file http_parser.cpp.
|
static |
URL decode a string.
| value | String to decode |
Decodes XX sequences back to original characters Handles both %20 and + as spaces
Definition at line 463 of file http_parser.cpp.
|
static |
URL encode a string.
| value | String to encode |
Encodes special characters as XX where XX is hex code Spaces are encoded as %20 (not +)
Definition at line 440 of file http_parser.cpp.