stdlib/http2View source ↗
http2
97 items · generated by scribe fromstdlib/http2.fd· synced 2026-11-15
Contents
- H2_DATA: (const)
- H2_FLAG_END_STREAM: (const)
- H2_NO_ERROR: (const)
- H2_SETTINGS_HEADER_TABLE_SIZE: (const)
- H2_IDLE: (const)
- H2_DEFAULT_WINDOW: (const)
- h2_preface (function)
- h2_type_name (function)
- h2_error_name (function)
- H2Frame (struct)
- h2_frame (function)
- h2_put_frame (function)
- h2_frame_encode (function)
- h2_frame_header (function)
- h2_frame_decode (function)
- h2_frames_decode (function)
- h2_data_frame (function)
- H2Priority (struct)
- h2_priority (function)
- h2_no_priority (function)
- h2_headers_frame (function)
- h2_headers_frame_ex (function)
- h2_priority_frame (function)
- h2_rst_stream_frame (function)
- h2_settings_frame (function)
- h2_settings_ack (function)
- h2_ping_frame (function)
- h2_goaway_frame (function)
- h2_window_update_frame (function)
- h2_continuation_frame (function)
- H2Info (struct)
- h2_parse (function)
- h2_frame_describe (function)
- H2Stream (struct)
- H2Conn (struct)
- h2_conn_new (function)
- h2_stream_index (function)
- h2_send (function)
- h2_flush (function)
- h2_read_frame (function)
- h2_conn_error (function)
- h2_conn_start (function)
- h2_process (function)
- h2_send_headers (function)
- h2_pump (function)
- h2_request (function)
- h2_response_fields (function)
- http2_set_handler (function)
- h2_server_step (function)
- http2_serve_conn (function)
- h2_conn_task (function)
- h2_accept_task (function)
- http2_stop (function)
- http2_listen_tasks (function)
- http2_serve (function)
- Http2Response (struct)
- http2_header (function)
- http2_connect (function)
- http2_request (function)
- http2_wait (function)
- http2_close (function)
- http2_get (function)
- http2_post (function)
- http2_get_many (function)
H2_DATA:
pub const H2_DATA: i64 = 0; pub const H2_HEADERS: i64 = 1; pub const H2_PRIORITY: i64 = 2; pub const H2_RST_STREAM: i64 = 3; pub const H2_SETTINGS: i64 = 4; pub const H2_PUSH_PROMISE: i64 = 5; pub const H2_PING: i64 = 6; pub const H2_GOAWAY: i64 = 7; pub const H2_WINDOW_UPDATE: i64 = 8; pub const H2_CONTINUATION: i64 = 9;Defined at line 44
H2_FLAG_END_STREAM:
pub const H2_FLAG_END_STREAM: i64 = 1; pub const H2_FLAG_ACK: i64 = 1; pub const H2_FLAG_END_HEADERS: i64 = 4; pub const H2_FLAG_PADDED: i64 = 8; pub const H2_FLAG_PRIORITY: i64 = 32;Defined at line 45
H2_NO_ERROR:
pub const H2_NO_ERROR: i64 = 0; pub const H2_PROTOCOL_ERROR: i64 = 1; pub const H2_INTERNAL_ERROR: i64 = 2; pub const H2_FLOW_CONTROL_ERROR: i64 = 3; pub const H2_SETTINGS_TIMEOUT: i64 = 4; pub const H2_STREAM_CLOSED: i64 = 5; pub const H2_FRAME_SIZE_ERROR: i64 = 6; pub const H2_REFUSED_STREAM: i64 = 7; pub const H2_CANCEL: i64 = 8; pub const H2_COMPRESSION_ERROR: i64 = 9; pub const H2_CONNECT_ERROR: i64 = 10; pub const H2_ENHANCE_YOUR_CALM: i64 = 11; pub const H2_INADEQUATE_SECURITY: i64 = 12; pub const H2_HTTP_1_1_REQUIRED: i64 = 13;Defined at line 46
H2_SETTINGS_HEADER_TABLE_SIZE:
pub const H2_SETTINGS_HEADER_TABLE_SIZE: i64 = 1; pub const H2_SETTINGS_ENABLE_PUSH: i64 = 2; pub const H2_SETTINGS_MAX_CONCURRENT_STREAMS: i64 = 3; pub const H2_SETTINGS_INITIAL_WINDOW_SIZE: i64 = 4; pub const H2_SETTINGS_MAX_FRAME_SIZE: i64 = 5; pub const H2_SETTINGS_MAX_HEADER_LIST_SIZE: i64 = 6;Defined at line 47
H2_IDLE:
Stream states (5.1); reserved states never occur (no push).
pub const H2_IDLE: i64 = 0; pub const H2_OPEN: i64 = 1; pub const H2_HALF_CLOSED_LOCAL: i64 = 2; pub const H2_HALF_CLOSED_REMOTE: i64 = 3; pub const H2_CLOSED: i64 = 4;Defined at line 49
H2_DEFAULT_WINDOW:
The default and largest window, the default frame size (6.5.2).
pub const H2_DEFAULT_WINDOW: i64 = 65535; pub const H2_MAX_WINDOW: i64 = 2147483647; pub const H2_DEFAULT_FRAME: i64 = 16384; pub const H2_MAX_FRAME: i64 = 16777215;Defined at line 51
h2_preface
The client connection preface (3.4): “PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n”.
pub fn h2_preface() -> Vec<i64> {Returns: Vec<i64>
Defined at line 59
h2_type_name
Name of a frame type, for logs and tests.
pub fn h2_type_name(t: i64) -> str {Parameters:
t:i64
Returns: str
Defined at line 64
h2_error_name
Name of an error code (7).
pub fn h2_error_name(e: i64) -> str {Parameters:
e:i64
Returns: str
Defined at line 99
H2Frame
A frame. length is the payload’s length (also set when only the header was read); ftype -1 means no frame (not enough bytes).
pub struct H2Frame {Fields:
| Name | Type |
|---|---|
length | i64 |
ftype | i64 |
flags | i64 |
stream | i64 |
payload | Vec<i64> |
Defined at line 149
h2_frame
pub fn h2_frame(ftype: i64, flags: i64, stream: i64, payload: Vec<i64>) -> H2Frame {Parameters:
ftype:i64flags:i64stream:i64payload:Vec<i64>
Returns: H2Frame
Defined at line 157
h2_put_frame
Append a frame’s 9-byte header and payload to out.
pub fn h2_put_frame(out: & mut Vec<i64>, f: H2Frame) {Parameters:
out:& mut Vec<i64>f:H2Frame
Defined at line 199
h2_frame_encode
A frame as bytes: header then payload.
pub fn h2_frame_encode(f: H2Frame) -> Vec<i64> {Parameters:
f:H2Frame
Returns: Vec<i64>
Defined at line 211
h2_frame_header
The frame header at at (payload left empty): ftype -1 when fewer than 9 bytes are there. The reserved bit of the stream id is dropped (4.1).
pub fn h2_frame_header(b: Vec<i64>, at: i64) -> H2Frame {Parameters:
b:Vec<i64>at:i64
Returns: H2Frame
Defined at line 219
h2_frame_decode
The whole frame at at: ftype -1 when it is not all there yet.
pub fn h2_frame_decode(b: Vec<i64>, at: i64) -> H2Frame {Parameters:
b:Vec<i64>at:i64
Returns: H2Frame
Defined at line 229
h2_frames_decode
Every frame in b from at, in order (stops at an incomplete one).
pub fn h2_frames_decode(b: Vec<i64>, at: i64) -> Vec<H2Frame> {Parameters:
b:Vec<i64>at:i64
Returns: Vec<H2Frame>
Defined at line 239
h2_data_frame
DATA (6.1). pad > 0 adds PADDED with that many zero bytes.
pub fn h2_data_frame(stream: i64, data: Vec<i64>, end_stream: bool, pad: i64) -> H2Frame {Parameters:
stream:i64data:Vec<i64>end_stream:boolpad:i64
Returns: H2Frame
Defined at line 262
H2Priority
Priority fields of HEADERS and PRIORITY (5.3, deprecated by RFC 9113 but still on the wire). weight is 1..256.
pub struct H2Priority {Fields:
| Name | Type |
|---|---|
exclusive | bool |
dep | i64 |
weight | i64 |
Defined at line 279
h2_priority
pub fn h2_priority(exclusive: bool, dep: i64, weight: i64) -> H2Priority {Parameters:
exclusive:booldep:i64weight:i64
Returns: H2Priority
Defined at line 285
h2_no_priority
pub fn h2_no_priority() -> H2Priority {Returns: H2Priority
Defined at line 291
h2_headers_frame
HEADERS (6.2) carrying a header block fragment.
pub fn h2_headers_frame(stream: i64, block: Vec<i64>, end_stream: bool, end_headers: bool) -> H2Frame {Parameters:
stream:i64block:Vec<i64>end_stream:boolend_headers:bool
Returns: H2Frame
Defined at line 307
h2_headers_frame_ex
HEADERS with padding (pad > 0) and priority fields (has_priority).
pub fn h2_headers_frame_ex(stream: i64, block: Vec<i64>, end_stream: bool, end_headers: bool, pad: i64, has_priority: bool, pr: H2Priority) -> H2Frame {Parameters:
stream:i64block:Vec<i64>end_stream:boolend_headers:boolpad:i64has_priority:boolpr:H2Priority
Returns: H2Frame
Defined at line 312
h2_priority_frame
PRIORITY (6.3).
pub fn h2_priority_frame(stream: i64, pr: H2Priority) -> H2Frame {Parameters:
stream:i64pr:H2Priority
Returns: H2Frame
Defined at line 335
h2_rst_stream_frame
RST_STREAM (6.4).
pub fn h2_rst_stream_frame(stream: i64, code: i64) -> H2Frame {Parameters:
stream:i64code:i64
Returns: H2Frame
Defined at line 342
h2_settings_frame
SETTINGS (6.5) with these identifiers and values.
pub fn h2_settings_frame(ids: Vec<i64>, vals: Vec<i64>) -> H2Frame {Parameters:
ids:Vec<i64>vals:Vec<i64>
Returns: H2Frame
Defined at line 349
h2_settings_ack
The acknowledgement of a SETTINGS frame.
pub fn h2_settings_ack() -> H2Frame {Returns: H2Frame
Defined at line 362
h2_ping_frame
PING (6.7): 8 opaque bytes (shorter data is padded with zeros).
pub fn h2_ping_frame(opaque: Vec<i64>, ack: bool) -> H2Frame {Parameters:
opaque:Vec<i64>ack:bool
Returns: H2Frame
Defined at line 367
h2_goaway_frame
GOAWAY (6.8).
pub fn h2_goaway_frame(last_stream: i64, code: i64, debug: str) -> H2Frame {Parameters:
last_stream:i64code:i64debug:str
Returns: H2Frame
Defined at line 386
h2_window_update_frame
WINDOW_UPDATE (6.9) for a stream, or the connection (stream 0).
pub fn h2_window_update_frame(stream: i64, increment: i64) -> H2Frame {Parameters:
stream:i64increment:i64
Returns: H2Frame
Defined at line 395
h2_continuation_frame
CONTINUATION (6.10).
pub fn h2_continuation_frame(stream: i64, block: Vec<i64>, end_headers: bool) -> H2Frame {Parameters:
stream:i64block:Vec<i64>end_headers:bool
Returns: H2Frame
Defined at line 402
H2Info
What a frame’s payload says. ok false: error is the error code and stream_error tells a stream error (RST_STREAM) from a connection error (GOAWAY). data is DATA’s data, the header block fragment of HEADERS and CONTINUATION, PING’s opaque bytes, or GOAWAY’s debug data.
pub struct H2Info {Fields:
| Name | Type |
|---|---|
ok | bool |
error | i64 |
stream_error | bool |
why | str |
data | Vec<i64> |
pad | i64 |
has_priority | bool |
priority | H2Priority |
code | i64 |
last_stream | i64 |
increment | i64 |
ids | Vec<i64> |
vals | Vec<i64> |
Defined at line 414
h2_parse
Parse and check a frame’s payload (RFC 9113 6). An unknown type is ok and carries nothing (it must be ignored, 5.5).
pub fn h2_parse(f: H2Frame) -> H2Info {Parameters:
f:H2Frame
Returns: H2Info
Defined at line 454
h2_frame_describe
One line describing a frame (tests, logs).
pub fn h2_frame_describe(f: H2Frame) -> str {Parameters:
f:H2Frame
Returns: str
Defined at line 589
H2Stream
A stream of a connection.
pub struct H2Stream {Fields:
| Name | Type |
|---|---|
id | i64 |
state | i64 |
send_window | i64 |
recv_window | i64 |
names | Vec<str> |
vals | Vec<str> |
got_headers | bool |
body | Vec<i64> |
pending | Vec<i64> |
pending_end | bool |
handled | bool |
reset | i64 |
Defined at line 639
H2Conn
One HTTP/2 connection, either end.
pub struct H2Conn {Fields:
| Name | Type |
|---|---|
fd | i64 |
client | bool |
authority | str |
ok | bool |
inbuf | Vec<i64> |
inpos | i64 |
out | Vec<i64> |
enc | Hpack |
dec | Hpack |
peer_window | i64 |
peer_max_frame | i64 |
peer_max_streams | i64 |
send_window | i64 |
recv_window | i64 |
streams | Vec<H2Stream> |
next_id | i64 |
last_peer | i64 |
got_settings | bool |
goaway | bool |
error | i64 |
why | str |
cont_stream | i64 |
cont_flags | i64 |
cont_block | Vec<i64> |
Defined at line 661
h2_conn_new
A connection over socket fd. With fd -1 nothing is read or written: frames queued by h2_send stay in out (tests feed h2_process by hand).
pub fn h2_conn_new(fd: i64, client: bool, authority: str) -> H2Conn {Parameters:
fd:i64client:boolauthority:str
Returns: H2Conn
Defined at line 707
h2_stream_index
Index of stream id in the table, -1 when it is not there (idle, or closed and forgotten).
pub fn h2_stream_index(c: & H2Conn, id: i64) -> i64 {Parameters:
c:& H2Connid:i64
Returns: i64
Defined at line 719
h2_send
Queue a frame (written by h2_flush).
pub fn h2_send(c: & mut H2Conn, f: H2Frame) {Parameters:
c:& mut H2Connf:H2Frame
Defined at line 731
h2_flush
Write the queued frames. False when the connection failed.
pub fn h2_flush(c: & mut H2Conn) -> bool {Parameters:
c:& mut H2Conn
Returns: bool
Defined at line 736
h2_read_frame
Read the next frame (ftype -1 at the end of the input, on a timeout, or when the frame is larger than we allow: then c.error is set).
pub fn h2_read_frame(c: & mut H2Conn, timeout_ms: i64) -> H2Frame {Parameters:
c:& mut H2Conntimeout_ms:i64
Returns: H2Frame
Defined at line 787
h2_conn_error
A connection error (5.4.1): GOAWAY with the last stream the peer opened, then the connection is done.
pub fn h2_conn_error(c: & mut H2Conn, code: i64, why: str) {Parameters:
c:& mut H2Conncode:i64why:str
Defined at line 807
h2_conn_start
Queue what an end sends first: the preface (client), our SETTINGS, and a WINDOW_UPDATE that opens the connection window.
pub fn h2_conn_start(c: & mut H2Conn) {Parameters:
c:& mut H2Conn
Defined at line 867
h2_process
Handle one frame the peer sent. False when the connection is over (an error, or GOAWAY with nothing left to finish).
pub fn h2_process(c: & mut H2Conn, f: H2Frame) -> bool {Parameters:
c:& mut H2Connf:H2Frame
Returns: bool
Defined at line 1133
h2_send_headers
Queue the header block of stream id as HEADERS and as many CONTINUATION frames as the peer’s frame size needs.
pub fn h2_send_headers(c: & mut H2Conn, id: i64, names: Vec<str>, vals: Vec<str>, end_stream: bool) {Parameters:
c:& mut H2Connid:i64names:Vec<str>vals:Vec<str>end_stream:bool
Defined at line 1247
h2_pump
Send what the windows allow of every stream’s pending body, a frame per stream in turn, so streams share the connection.
pub fn h2_pump(c: & mut H2Conn) {Parameters:
c:& mut H2Conn
Defined at line 1289
h2_request
The request a handler gets: method and path from the pseudo-header fields, the other fields as headers (with “host” from :authority), the body. version is “2”.
pub fn h2_request(s: H2Stream) -> HttpRequest {Parameters:
s:H2Stream
Returns: HttpRequest
Defined at line 1346
h2_response_fields
Turn a response of module http (build_response: “HTTP/1.1 200 OK”, headers, body) into HTTP/2 fields and a body. Text that is not such a response is sent as a 200 text/plain body.
pub fn h2_response_fields(resp: str, names: & mut Vec<str>, vals: & mut Vec<str>) -> str {Parameters:
resp:strnames:& mut Vec<str>vals:& mut Vec<str>
Returns: str
Defined at line 1388
http2_set_handler
The handler the server calls (http2_serve and http2_listen_tasks set it).
pub fn http2_set_handler(handler: fn(HttpRequest) -> str) {Parameters:
handler:fn(HttpRequest) -> str
Defined at line 1446
h2_server_step
After a frame: run the handlers of complete requests, send what the windows allow, forget finished streams.
pub fn h2_server_step(c: & mut H2Conn) {Parameters:
c:& mut H2Conn
Defined at line 1452
http2_serve_conn
Serve one accepted connection until it closes: the preface, then frames of any number of streams. Returns 0.
pub fn http2_serve_conn(fd: i64) -> i64 {Parameters:
fd:i64
Returns: i64
Defined at line 1460
h2_conn_task
A connection’s task (task_go needs a name).
pub fn h2_conn_task(fd: i64) -> i64 {Parameters:
fd:i64
Returns: i64
Defined at line 1506
h2_accept_task
Take connections off the listening socket, each its own task, until http2_stop().
pub fn h2_accept_task(fd: i64) -> i64 {Parameters:
fd:i64
Returns: i64
Defined at line 1512
http2_stop
Ask the server to stop accepting; connections finish their streams.
pub fn http2_stop() {Defined at line 1526
http2_listen_tasks
Serve a listening socket from tasks and return: they run whenever the caller waits (task_sleep, task_run, a client call).
pub fn http2_listen_tasks(fd: i64, handler: fn(HttpRequest) -> str) {Parameters:
fd:i64handler:fn(HttpRequest) -> str
Defined at line 1532
http2_serve
Serve HTTP/2 (h2c, prior knowledge) on port with a handler of module http, until http2_stop(). False if the port cannot be opened.
pub fn http2_serve(port: i64, handler: fn(HttpRequest) -> str) -> bool {Parameters:
port:i64handler:fn(HttpRequest) -> str
Returns: bool
Defined at line 1540
Http2Response
A response. status 0: no response (error says why).
pub struct Http2Response {Fields:
| Name | Type |
|---|---|
status | i64 |
names | Vec<str> |
vals | Vec<str> |
body | str |
stream | i64 |
error | str |
Defined at line 1553
http2_header
A response header (name in lowercase), "" when absent.
pub fn http2_header(r: Http2Response, name: str) -> str {Parameters:
r:Http2Responsename:str
Returns: str
Defined at line 1569
http2_connect
Connect to host:port and start HTTP/2 with prior knowledge: the preface and our SETTINGS go out at once. ok false on failure.
pub fn http2_connect(host: str, port: i64) -> H2Conn {Parameters:
host:strport:i64
Returns: H2Conn
Defined at line 1582
http2_request
Open a stream with a request; returns its id (-1 if the connection cannot take one). names/vals are extra fields (lowercase names).
pub fn http2_request(c: & mut H2Conn, method: str, path: str, names: Vec<str>, vals: Vec<str>, body: str) -> i64 {Parameters:
c:& mut H2Connmethod:strpath:strnames:Vec<str>vals:Vec<str>body:str
Returns: i64
Defined at line 1597
http2_wait
Read frames until stream id has its whole response, and return it (the stream is then forgotten).
pub fn http2_wait(c: & mut H2Conn, id: i64) -> Http2Response {Parameters:
c:& mut H2Connid:i64
Returns: Http2Response
Defined at line 1649
http2_close
Say goodbye (GOAWAY) and close the socket.
pub fn http2_close(c: & mut H2Conn) {Parameters:
c:& mut H2Conn
Defined at line 1692
http2_get
GET path from host:port over h2c with prior knowledge.
pub fn http2_get(host: str, port: i64, path: str) -> Http2Response {Parameters:
host:strport:i64path:str
Returns: Http2Response
Defined at line 1705
http2_post
POST body to path.
pub fn http2_post(host: str, port: i64, path: str, content_type: str, body: str) -> Http2Response {Parameters:
host:strport:i64path:strcontent_type:strbody:str
Returns: Http2Response
Defined at line 1717
http2_get_many
GET every path at once on one connection (each its own stream, all sent before any response is read); the responses in the order of paths.
pub fn http2_get_many(host: str, port: i64, paths: Vec<str>) -> Vec<Http2Response> {Parameters:
host:strport:i64paths:Vec<str>
Returns: Vec<Http2Response>
Defined at line 1734
Generated by scribe, the Fides documentation generator