Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
Loading...
Searching...
No Matches
orbit::http::websocket::detail Namespace Reference

Classes

struct  FrameHeader
 A decoded RFC 6455 frame header. More...
 

Enumerations

enum class  FrameStatus { NeedHeader , NeedPayload , Complete , Invalid }
 Progress of parsing the frame at the front of a buffer. More...
 

Functions

bool parse_frame_header (const std::vector< char > &buffer, FrameHeader &header)
 Decodes an RFC 6455 frame header from the front of a buffer.
 
FrameStatus inspect_frame (const std::vector< char > &buffer, FrameHeader &header)
 Parses the frame header at the front of buffer.
 
void unmask_payload (std::string &payload, const uint8_t mask_key[4])
 Unmasks a frame payload in place using the frame's masking key.
 
bool is_valid_utf8 (std::string_view data)
 
bool is_valid_close_code (uint16_t code)
 True if a close frame may carry this status code (RFC 6455 section 7.4).
 

Enumeration Type Documentation

◆ FrameStatus

Progress of parsing the frame at the front of a buffer.

Enumerator
NeedHeader 

The frame header has not fully arrived.

NeedPayload 

The header is parsed (payload_length is known); the payload has not fully arrived.

Complete 

The whole frame is in the buffer.

Invalid 

The frame violates RFC 6455 and the connection must be failed.

Function Documentation

◆ inspect_frame()

FrameStatus orbit::http::websocket::detail::inspect_frame ( const std::vector< char > &  buffer,
FrameHeader &  header 
)

Parses the frame header at the front of buffer.

Unlike parse_frame_header(), this distinguishes a protocol violation from a frame that is still arriving, and reports the payload length as soon as the header is available so callers can reject oversized frames without buffering them.

◆ is_valid_close_code()

bool orbit::http::websocket::detail::is_valid_close_code ( uint16_t  code)

True if a close frame may carry this status code (RFC 6455 section 7.4).

◆ is_valid_utf8()

bool orbit::http::websocket::detail::is_valid_utf8 ( std::string_view  data)

True if data is well-formed UTF-8 (no overlong forms, surrogates, or code points above U+10FFFF), as RFC 6455 requires of text messages and close reasons.

◆ parse_frame_header()

bool orbit::http::websocket::detail::parse_frame_header ( const std::vector< char > &  buffer,
FrameHeader &  header 
)

Decodes an RFC 6455 frame header from the front of a buffer.

Returns false when the buffer does not yet hold the complete header and payload, so the caller can wait for more data. On success, header_length is the number of bytes preceding the payload, including the extended length and masking key when present.

Parameters
bufferThe raw bytes received so far.
headerPopulated on success.
Returns
True if a complete frame is available at the front of the buffer.

◆ unmask_payload()

void orbit::http::websocket::detail::unmask_payload ( std::string &  payload,
const uint8_t  mask_key[4] 
)

Unmasks a frame payload in place using the frame's masking key.

Parameters
payloadThe masked payload bytes.
mask_keyThe 4-byte masking key from the frame header.