26 std::map<std::string, std::string>
headers;
52 std::string_view host, std::string_view path, uint16_t port,
53 const std::map<std::string, std::string>& extra_headers = {})
67 const std::string& expected_key)
127 -> std::map<std::string, std::string>;
158 static auto sha1_hash(
const std::string& data) -> std::vector<uint8_t>;
Implements WebSocket HTTP/1.1 upgrade handshake (RFC 6455).
static auto generate_websocket_key() -> std::string
Generates a random Sec-WebSocket-Key (client-side).
static auto base64_encode(const std::vector< uint8_t > &data) -> std::string
Encodes binary data to Base64.
static auto extract_status_code(const std::string &response) -> int
Extracts the status code from an HTTP response.
static auto create_server_response(const std::string &client_key) -> std::string
Creates a WebSocket handshake response (server-side).
static auto create_client_handshake(std::string_view host, std::string_view path, uint16_t port, const std::map< std::string, std::string > &extra_headers={}) -> std::string
Creates a WebSocket handshake request (client-side).
static auto validate_server_response(const std::string &response, const std::string &expected_key) -> ws_handshake_result
Validates a WebSocket handshake response (client-side).
static auto parse_headers(const std::string &http_message) -> std::map< std::string, std::string >
Parses HTTP headers from a request or response.
static auto sha1_hash(const std::string &data) -> std::vector< uint8_t >
Computes SHA-1 hash of input data.
static auto parse_client_request(const std::string &request) -> ws_handshake_result
Parses a WebSocket handshake request (server-side).
static auto calculate_accept_key(const std::string &client_key) -> std::string
Calculates Sec-WebSocket-Accept from client key.
Result of a WebSocket handshake operation.
bool success
Whether the handshake was successful.
std::map< std::string, std::string > headers
Parsed HTTP headers.
std::string error_message
Error message if success is false.