← all modules
module

stdlib::http::h2

defined in C:\Users\bye45\.glide\bin/src/stdlib/http/h2.glide

Frame type opcodes (RFC 7540 §11.2). Use these symbolic names instead

struct struct FrameType

Frame type opcodes (RFC 7540 §11.2). Use these symbolic names instead of literal integers when calling write_frame / matching headers.

glide
write_frame_bytes(buf, FrameType::headers(),
                  FrameFlag::end_headers(), 1, hdr_payload);
struct struct FrameFlag

Frame flag bits (RFC 7540 §6). Combine with | for multi-flag frames (e.g. last HEADERS frame with no body sets both end_headers and end_stream). ack and end_stream happen to share bit 1 — they're never used on the same frame type.

glide
let f: int = FrameFlag::end_headers() | FrameFlag::end_stream();
write_frame_bytes(buf, FrameType::headers(), f, 1, hdr_payload);
struct struct FrameHeader
fn fn write_frame(buf: *ByteBuffer, frame_type: int, flags: int, stream_id: int, payload: string)

Append a 9-byte frame header to buf, then payload. RFC 7540 §4.1. Use write_frame_bytes for binary payloads that may contain NUL — this entry truncates at the first NUL because Glide string is a cstring.

glide
let buf: *ByteBuffer = ByteBuffer::new();  defer buf.free();
write_frame(buf, FrameType::ping(), 0, 0, "ABCDEFGH");   // 8-byte ping
tls.write_bytes(buf.data, buf.len);
fn fn write_frame_bytes(buf: *ByteBuffer, frame_type: int, flags: int, stream_id: int, payload: *ByteBuffer)

Same as write_frame but pulls the payload from a ByteBuffer with explicit length. Use this for HPACK-encoded headers and for any payload that may carry NUL bytes mid-frame.

glide
let hdrs: *ByteBuffer = ByteBuffer::new();  defer hdrs.free();
enc.encode_header(hdrs, ":method", "GET");
enc.encode_header(hdrs, ":path", "/");
let buf: *ByteBuffer = ByteBuffer::new();   defer buf.free();
let f: int = FrameFlag::end_headers() | FrameFlag::end_stream();
write_frame_bytes(buf, FrameType::headers(), f, 1, hdrs);
fn fn read_frame_header(raw: *ByteBuffer, pos: int) -> !*FrameHeader

Parse a 9-byte frame header at pos in raw. Returns the header and the new position (header end; payload starts here). Binary safe (uses ByteBuffer.at, not string indexing).

glide
let r: !*FrameHeader = read_frame_header(rx_buf, 0);
if r.ok {
    let h: *FrameHeader = r.val;
    println!("type", h.frame_type, "len", h.length, "stream", h.stream_id);
}
fn fn h2_preface() -> string

The 24-byte HTTP/2 connection preface (RFC 7540 §3.5). Send this immediately after the TLS handshake (or the bare TCP connection for h2c). H2Conn::over does this for you.

glide
let preface: string = h2_preface();
preface is "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
fn fn settings_payload_empty() -> string

Empty SETTINGS frame (acknowledges defaults). Use with flags=0 to announce our settings, or with FrameFlag::ack() to ack the peer's.

glide
Acknowledge the peer's SETTINGS:
write_frame(buf, FrameType::settings(),
            FrameFlag::ack(), 0, settings_payload_empty());
fn fn settings_pair_to(buf: *ByteBuffer, key: int, value: int)

Append a single 6-byte SETTINGS entry (16-bit key + 32-bit value). Settings keys (RFC 7540 §6.5.2): 0x1 HEADER_TABLE_SIZE 0x2 ENABLE_PUSH 0x3 MAX_CONCURRENT_STREAMS 0x4 INITIAL_WINDOW_SIZE 0x5 MAX_FRAME_SIZE 0x6 MAX_HEADER_LIST_SIZE

glide
let pl: *ByteBuffer = ByteBuffer::new();  defer pl.free();
settings_pair_to(pl, 2, 0);          // ENABLE_PUSH = false
settings_pair_to(pl, 4, 1048576);    // INITIAL_WINDOW_SIZE = 1 MiB
write_frame_bytes(buf, FrameType::settings(), 0, 0, pl);
fn fn window_update_to(buf: *ByteBuffer, increment: int)

Append a 4-byte WINDOW_UPDATE payload (31-bit increment + reserved bit).

glide
let wu: *ByteBuffer = ByteBuffer::new();  defer wu.free();
window_update_to(wu, 65535);   // grow stream window by 64 KiB
write_frame_bytes(buf, FrameType::window_update(), 0, stream_id, wu);
struct struct H2Conn
struct struct H2Response