![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
HTTP/2 server connection and stream state machine (see n_http2_server.h). More...
#include "nilorea/n_http2_server.h"#include "nilorea/n_common.h"#include "nilorea/n_log.h"#include <stdlib.h>#include <string.h>Go to the source code of this file.
Data Structures | |
| struct | H2_STREAM |
| one client-initiated stream More... | |
| struct | H2BUF |
| a growable byte buffer for the read stream and the per-stream accumulators More... | |
| struct | N_H2_SERVER |
| server connection state More... | |
Macros | |
| #define | H2_DEFAULT_MAX_FRAME 16384 |
| the initial SETTINGS_MAX_FRAME_SIZE, fixed by RFC 7540 6.5.2 | |
| #define | H2_DEFAULT_WINDOW 65535 |
| the initial connection flow-control window, fixed by RFC 7540 6.9.2 | |
| #define | H2_SRV_RECV_WINDOW H2_WIN_MAX |
| the connection and stream receive window we advertise | |
| #define | H2_WIN_MAX 0x7FFFFFFF |
| the largest value a flow-control window may hold (RFC 7540 6.9.1) | |
Functions | |
| static int | h2buf_append (H2BUF *b, const unsigned char *p, size_t n) |
| append n bytes to b, growing it as needed. | |
| static void | h2buf_free (H2BUF *b) |
| release a buffer's storage | |
| static void | h2buf_shift (H2BUF *b, size_t n) |
| drop the first n bytes of b | |
| const char * | n_http2_server_error (const N_H2_SERVER *s) |
| the reason the connection failed, or NULL when none was recorded | |
| void | n_http2_server_free (N_H2_SERVER **srv) |
| free a server connection and NULL the caller's pointer | |
| int | n_http2_server_goaway (N_H2_SERVER *s, uint32_t error_code) |
| send GOAWAY, naming the last stream we processed | |
| int | n_http2_server_handshake (N_H2_SERVER *s) |
| read and validate the client connection preface, then send ours | |
| N_H2_SERVER * | n_http2_server_new (void *io, n_h2_srv_read_fn rd, n_h2_srv_write_fn wr) |
| create a server connection over the given I/O callbacks | |
| size_t | n_http2_server_request_count (const N_H2_SERVER *s) |
| the number of requests delivered to the callback so far | |
| int | n_http2_server_respond (N_H2_SERVER *s, uint32_t stream_id, const N_H2_HEADER *headers, size_t nheaders, const unsigned char *body, size_t body_len) |
| write a complete response on a stream (HEADERS then DATA, END_STREAM) | |
| int | n_http2_server_rst_stream (N_H2_SERVER *s, uint32_t stream_id, uint32_t error_code) |
| abort one stream with RST_STREAM | |
| int | n_http2_server_run (N_H2_SERVER *s, n_h2_srv_request_cb cb, void *user_data) |
| serve the connection until it ends | |
| static int | srv_apply_data (N_H2_SERVER *s, const N_H2_FRAME *fr) |
| take one DATA frame onto its stream and replenish the receive windows | |
| static int | srv_apply_headers (N_H2_SERVER *s, const N_H2_FRAME *fr) |
| take one HEADERS or CONTINUATION frame | |
| static int | srv_apply_settings (N_H2_SERVER *s, const N_H2_FRAME *fr) |
| apply a peer SETTINGS payload to our send-side state | |
| static int | srv_apply_window_update (N_H2_SERVER *s, const N_H2_FRAME *fr) |
| add a WINDOW_UPDATE increment to the matching send window | |
| static int | srv_fill (N_H2_SERVER *s) |
| pull one chunk from the peer into the read buffer. | |
| static int | srv_finish_headers (N_H2_SERVER *s) |
| HPACK-decode the accumulated header block onto its stream. | |
| static int | srv_handle_frame (N_H2_SERVER *s, const N_H2_FRAME *fr) |
| handle one received frame. | |
| static int | srv_headers_payload (const N_H2_FRAME *fr, const unsigned char **p_out, size_t *len_out) |
| strip the pad-length prefix and priority fields of a HEADERS payload. | |
| static int | srv_need (N_H2_SERVER *s, size_t n) |
| make sure at least n bytes are buffered. | |
| static int | srv_next_frame (N_H2_SERVER *s, N_H2_FRAME *fr, size_t *consumed) |
| read the next complete frame into fr (aliasing the read buffer). | |
| static H2_STREAM * | srv_next_ready (N_H2_SERVER *s) |
| the lowest-numbered stream whose request is complete and undelivered | |
| static int | srv_pump_one (N_H2_SERVER *s) |
| read and handle one frame. | |
| static void | srv_put_setting (unsigned char *out, uint16_t id, uint32_t value) |
| write one 6-byte SETTINGS entry (identifier then value) into out | |
| static int | srv_send (N_H2_SERVER *s, int type, int flags, uint32_t sid, const unsigned char *payload, size_t len) |
| write one frame (header then payload). | |
| static void | srv_stream_close (H2_STREAM *st) |
| release a stream slot and everything it owns | |
| static H2_STREAM * | srv_stream_find (N_H2_SERVER *s, uint32_t id) |
| the stream with this id, or NULL | |
| static H2_STREAM * | srv_stream_open (N_H2_SERVER *s, uint32_t id) |
| open a stream, or NULL when the table is full | |
| static int | srv_window_update (N_H2_SERVER *s, uint32_t sid, uint32_t inc) |
| send a WINDOW_UPDATE for sid with the given increment | |
HTTP/2 server connection and stream state machine (see n_http2_server.h).
Definition in file n_http2_server.c.
| struct H2_STREAM |
one client-initiated stream
Definition at line 52 of file n_http2_server.c.
| Data Fields | ||
|---|---|---|
| H2BUF | body | accumulated request body |
| int | delivered | the request was handed to the callback |
| int | end_stream | END_STREAM seen: the request is complete. |
| N_H2_HEADER * | hdrs | decoded request headers (owned), or NULL |
| int | headers_done | END_HEADERS seen: the header block decoded. |
| uint32_t | id | the stream identifier |
| int | in_use | 1 when the slot holds a stream |
| size_t | nhdrs | number of decoded headers |
| int | reset | RST_STREAM received, or the request was refused. |
| int64_t | send_win | our remaining send window for this stream |
| struct H2BUF |
a growable byte buffer for the read stream and the per-stream accumulators
Definition at line 45 of file n_http2_server.c.
| Data Fields | ||
|---|---|---|
| size_t | cap | bytes allocated |
| unsigned char * | data | storage, or NULL when empty |
| size_t | len | bytes held |
| struct N_H2_SERVER |
server connection state
opaque HTTP/2 server connection state (streams, windows, HPACK contexts)
Definition at line 66 of file n_http2_server.c.
| Data Fields | ||
|---|---|---|
| N_H2_HPACK * | dec | HPACK decoder for the client-to-server direction. |
| int | eof | the peer closed the connection |
| const char * | err | the reason the connection failed, or NULL |
| int | goaway_recv | the peer sent GOAWAY |
| H2BUF | hblock | header-block fragment accumulator |
| int | hblock_end_stream | END_STREAM of the HEADERS that opened the block. |
| uint32_t | hblock_sid | the stream whose header block is in progress, 0 = none |
| void * | io | opaque I/O handle for the callbacks |
| int | io_failed | a read or write callback failed |
| uint32_t | last_stream_id | the highest client stream id seen |
| size_t | nrequests | requests delivered to the callback |
| int64_t | peer_initial_win | the peer's SETTINGS_INITIAL_WINDOW_SIZE |
| size_t | peer_max_frame | the peer's SETTINGS_MAX_FRAME_SIZE |
| H2BUF | rb | the wire read buffer |
| n_h2_srv_read_fn | rd | read callback |
| int64_t | send_win_conn | our remaining connection send window |
| int | settings_acked | the peer acknowledged our SETTINGS |
| H2_STREAM | streams[128] | the stream table |
| n_h2_srv_write_fn | wr | write callback |
| #define H2_DEFAULT_MAX_FRAME 16384 |
the initial SETTINGS_MAX_FRAME_SIZE, fixed by RFC 7540 6.5.2
Definition at line 42 of file n_http2_server.c.
Referenced by n_http2_server_new(), and srv_apply_settings().
| #define H2_DEFAULT_WINDOW 65535 |
the initial connection flow-control window, fixed by RFC 7540 6.9.2
Definition at line 40 of file n_http2_server.c.
Referenced by n_http2_server_handshake(), and n_http2_server_new().
| #define H2_SRV_RECV_WINDOW H2_WIN_MAX |
the connection and stream receive window we advertise
Definition at line 38 of file n_http2_server.c.
Referenced by n_http2_server_handshake().
| #define H2_WIN_MAX 0x7FFFFFFF |
the largest value a flow-control window may hold (RFC 7540 6.9.1)
Definition at line 36 of file n_http2_server.c.
Referenced by srv_apply_settings(), and srv_apply_window_update().
|
static |
append n bytes to b, growing it as needed.
Returns 0 on success.
Definition at line 93 of file n_http2_server.c.
References H2BUF::cap, H2BUF::data, and H2BUF::len.
Referenced by srv_apply_data(), srv_apply_headers(), and srv_fill().
|
static |
release a buffer's storage
Definition at line 123 of file n_http2_server.c.
References H2BUF::cap, H2BUF::data, and H2BUF::len.
Referenced by n_http2_server_free(), and srv_stream_close().
|
static |
drop the first n bytes of b
Definition at line 113 of file n_http2_server.c.
References H2BUF::data, and H2BUF::len.
Referenced by n_http2_server_handshake(), and srv_pump_one().
| const char * n_http2_server_error | ( | const N_H2_SERVER * | s | ) |
the reason the connection failed, or NULL when none was recorded
Definition at line 833 of file n_http2_server.c.
References N_H2_SERVER::err.
Referenced by server_fn(), test_continuation(), test_guards(), test_handshake_errors(), and test_send_window_stall().
| void n_http2_server_free | ( | N_H2_SERVER ** | srv | ) |
free a server connection and NULL the caller's pointer
Definition at line 602 of file n_http2_server.c.
References N_H2_SERVER::dec, h2buf_free(), N_H2_SERVER::hblock, N_H2_SRV_MAX_STREAMS, n_http2_hpack_free(), N_H2_SERVER::rb, srv_stream_close(), and N_H2_SERVER::streams.
Referenced by server_fn(), test_callback_stop(), test_continuation(), test_dribbled_reads(), test_get(), test_guards(), test_handshake(), test_handshake_errors(), test_multiplex(), test_ping_goaway(), test_post_body(), test_rst_stream(), test_send_flow_control(), and test_send_window_stall().
| int n_http2_server_goaway | ( | N_H2_SERVER * | srv, |
| uint32_t | error_code ) |
send GOAWAY, naming the last stream we processed
| srv | the server connection, not NULL |
| error_code | an N_H2_ERR_* code |
< GOAWAY
Definition at line 817 of file n_http2_server.c.
References __n_assert, N_H2_SERVER::io_failed, N_H2_SERVER::last_stream_id, N_H2_GOAWAY, and srv_send().
Referenced by n_http2_server_run().
| int n_http2_server_handshake | ( | N_H2_SERVER * | srv | ) |
read and validate the client connection preface, then send ours
Reads the 24-byte preface, requires the client's first frame to be SETTINGS (RFC 7540 3.5), acknowledges it, and sends our own SETTINGS plus the connection-level WINDOW_UPDATE that opens our receive window.
| srv | the server connection, not NULL |
< SETTINGS
< SETTINGS
< SETTINGS/PING: acknowledgement
Definition at line 617 of file n_http2_server.c.
References __n_assert, H2BUF::data, N_H2_SERVER::err, N_H2_FRAME::flags, H2_DEFAULT_WINDOW, H2_SRV_RECV_WINDOW, h2buf_shift(), N_H2_FLAG_ACK, N_H2_PREFACE, N_H2_SETTINGS, N_H2_SETTINGS_ENABLE_PUSH, N_H2_SETTINGS_INITIAL_WINDOW_SIZE, N_H2_SETTINGS_MAX_CONCURRENT_STREAMS, N_H2_SRV_MAX_STREAMS, N_H2_SERVER::rb, srv_handle_frame(), srv_need(), srv_next_frame(), srv_put_setting(), srv_send(), srv_window_update(), N_H2_FRAME::stream_id, and N_H2_FRAME::type.
Referenced by server_fn(), test_callback_stop(), test_continuation(), test_dribbled_reads(), test_get(), test_guards(), test_handshake(), test_handshake_errors(), test_multiplex(), test_ping_goaway(), test_post_body(), test_rst_stream(), test_send_flow_control(), and test_send_window_stall().
| N_H2_SERVER * n_http2_server_new | ( | void * | io, |
| n_h2_srv_read_fn | rd, | ||
| n_h2_srv_write_fn | wr ) |
create a server connection over the given I/O callbacks
| io | opaque handle handed to the callbacks |
| rd | read callback, not NULL |
| wr | write callback, not NULL |
Definition at line 579 of file n_http2_server.c.
References __n_assert, N_H2_SERVER::dec, H2_DEFAULT_MAX_FRAME, H2_DEFAULT_WINDOW, N_H2_SERVER::io, LOG_ERR, n_http2_hpack_new(), n_log, N_H2_SERVER::peer_initial_win, N_H2_SERVER::peer_max_frame, N_H2_SERVER::rd, N_H2_SERVER::send_win_conn, and N_H2_SERVER::wr.
Referenced by server_fn(), test_callback_stop(), test_continuation(), test_dribbled_reads(), test_get(), test_guards(), test_handshake(), test_handshake_errors(), test_multiplex(), test_ping_goaway(), test_post_body(), test_rst_stream(), test_send_flow_control(), and test_send_window_stall().
| size_t n_http2_server_request_count | ( | const N_H2_SERVER * | s | ) |
the number of requests delivered to the callback so far
Definition at line 837 of file n_http2_server.c.
References N_H2_SERVER::nrequests.
Referenced by test_get(), and test_guards().
| int n_http2_server_respond | ( | N_H2_SERVER * | srv, |
| uint32_t | stream_id, | ||
| const N_H2_HEADER * | headers, | ||
| size_t | nheaders, | ||
| const unsigned char * | body, | ||
| size_t | body_len ) |
write a complete response on a stream (HEADERS then DATA, END_STREAM)
headers must start with the :status pseudo-header and hold no connection-specific field (RFC 7540 8.1.2.2 forbids them). The body is split into DATA frames at the peer's SETTINGS_MAX_FRAME_SIZE and paced by the stream and connection send windows, pumping incoming frames whenever a window is exhausted.
| srv | the server connection, not NULL |
| stream_id | the stream to answer |
| headers | the response header fields, :status first, not NULL |
| nheaders | number of header fields |
| body | the response body, or NULL for none |
| body_len | the body length |
< HEADERS/PUSH_PROMISE/CONTINUATION: header block complete
< DATA/HEADERS: last frame of the stream
< HEADERS
< CONTINUATION
< DATA
< DATA/HEADERS: last frame of the stream
Definition at line 725 of file n_http2_server.c.
References __n_assert, N_H2_SERVER::err, N_H2_CONTINUATION, N_H2_DATA, N_H2_FLAG_END_HEADERS, N_H2_FLAG_END_STREAM, N_H2_HEADERS, n_http2_hpack_encode(), N_H2_SERVER::peer_max_frame, H2_STREAM::reset, H2_STREAM::send_win, N_H2_SERVER::send_win_conn, srv_pump_one(), srv_send(), srv_stream_find(), and N_H2_HEADER::value.
Referenced by h2_on_request(), and on_request().
| int n_http2_server_rst_stream | ( | N_H2_SERVER * | srv, |
| uint32_t | stream_id, | ||
| uint32_t | error_code ) |
abort one stream with RST_STREAM
| srv | the server connection, not NULL |
| stream_id | the stream to reset |
| error_code | an N_H2_ERR_* code |
< RST_STREAM
Definition at line 807 of file n_http2_server.c.
References __n_assert, N_H2_RST_STREAM, and srv_send().
Referenced by srv_apply_data(), and srv_apply_headers().
| int n_http2_server_run | ( | N_H2_SERVER * | srv, |
| n_h2_srv_request_cb | cb, | ||
| void * | user_data ) |
serve the connection until it ends
Reads frames, reassembles requests, and calls cb once per complete request. Returns when the peer closes or sends GOAWAY, when the callback returns -1, or on an error.
| srv | the handshaked server connection, not NULL |
| cb | the request callback, not NULL |
| user_data | opaque pointer handed to the callback |
< graceful shutdown
< graceful shutdown
Definition at line 661 of file n_http2_server.c.
References __n_assert, N_H2_REQUEST::authority, H2_STREAM::body, N_H2_REQUEST::body, N_H2_REQUEST::body_len, H2BUF::data, H2_STREAM::delivered, N_H2_SERVER::eof, N_H2_SERVER::goaway_recv, H2_STREAM::hdrs, N_H2_REQUEST::headers, H2_STREAM::id, H2_STREAM::in_use, N_H2_SERVER::io_failed, H2BUF::len, N_H2_REQUEST::method, N_H2_ERR_NO_ERROR, N_H2_SRV_MAX_STREAMS, n_http2_server_goaway(), N_H2_HEADER::name, H2_STREAM::nhdrs, N_H2_REQUEST::nheaders, N_H2_SERVER::nrequests, N_H2_REQUEST::path, H2_STREAM::reset, N_H2_REQUEST::scheme, srv_next_ready(), srv_pump_one(), srv_stream_close(), srv_stream_find(), stop(), N_H2_REQUEST::stream_id, N_H2_SERVER::streams, and N_H2_HEADER::value.
Referenced by server_fn(), test_callback_stop(), test_continuation(), test_dribbled_reads(), test_get(), test_guards(), test_multiplex(), test_ping_goaway(), test_post_body(), test_rst_stream(), test_send_flow_control(), and test_send_window_stall().
|
static |
take one DATA frame onto its stream and replenish the receive windows
< DATA/HEADERS/PUSH_PROMISE: a pad-length prefix is present
< processing capacity exceeded
< DATA/HEADERS: last frame of the stream
Definition at line 417 of file n_http2_server.c.
References H2_STREAM::body, H2_STREAM::end_stream, N_H2_SERVER::err, N_H2_FRAME::flags, h2buf_append(), H2_STREAM::id, H2BUF::len, N_H2_FRAME::length, N_H2_ERR_ENHANCE_YOUR_CALM, N_H2_FLAG_END_STREAM, N_H2_FLAG_PADDED, N_H2_SRV_MAX_BODY, n_http2_server_rst_stream(), N_H2_FRAME::payload, H2_STREAM::reset, srv_stream_find(), srv_window_update(), and N_H2_FRAME::stream_id.
Referenced by srv_handle_frame().
|
static |
take one HEADERS or CONTINUATION frame
< HEADERS
< stream not processed
< DATA/HEADERS: last frame of the stream
< HEADERS/PUSH_PROMISE/CONTINUATION: header block complete
Definition at line 463 of file n_http2_server.c.
References N_H2_SERVER::err, N_H2_FRAME::flags, h2buf_append(), N_H2_SERVER::hblock, N_H2_SERVER::hblock_end_stream, N_H2_SERVER::hblock_sid, N_H2_SERVER::last_stream_id, H2BUF::len, N_H2_FRAME::length, N_H2_ERR_REFUSED_STREAM, N_H2_FLAG_END_HEADERS, N_H2_FLAG_END_STREAM, N_H2_HEADERS, n_http2_server_rst_stream(), N_H2_FRAME::payload, srv_finish_headers(), srv_headers_payload(), srv_stream_find(), srv_stream_open(), N_H2_FRAME::stream_id, and N_H2_FRAME::type.
Referenced by srv_handle_frame().
|
static |
apply a peer SETTINGS payload to our send-side state
< SETTINGS
< SETTINGS/PING: acknowledgement
Definition at line 358 of file n_http2_server.c.
References N_H2_SERVER::err, H2_DEFAULT_MAX_FRAME, H2_WIN_MAX, H2_STREAM::in_use, N_H2_FRAME::length, N_H2_FLAG_ACK, N_H2_MAX_FRAME_PAYLOAD, N_H2_SETTINGS, N_H2_SETTINGS_INITIAL_WINDOW_SIZE, N_H2_SETTINGS_MAX_FRAME_SIZE, N_H2_SRV_MAX_STREAMS, n_http2_settings_parse(), N_H2_FRAME::payload, N_H2_SERVER::peer_initial_win, N_H2_SERVER::peer_max_frame, H2_STREAM::send_win, srv_send(), N_H2_SERVER::streams, and N_H2_SETTING::value.
Referenced by srv_handle_frame().
|
static |
add a WINDOW_UPDATE increment to the matching send window
Definition at line 394 of file n_http2_server.c.
References N_H2_SERVER::err, H2_WIN_MAX, N_H2_FRAME::length, N_H2_FRAME::payload, H2_STREAM::send_win, N_H2_SERVER::send_win_conn, srv_stream_find(), and N_H2_FRAME::stream_id.
Referenced by srv_handle_frame().
|
static |
pull one chunk from the peer into the read buffer.
Returns 1 on bytes read, 0 on a clean end of stream, -1 on an I/O error.
Definition at line 179 of file n_http2_server.c.
References N_H2_SERVER::eof, N_H2_SERVER::err, h2buf_append(), N_H2_SERVER::io, N_H2_SERVER::io_failed, N_H2_SRV_READ_CHUNK, N_H2_SERVER::rb, and N_H2_SERVER::rd.
Referenced by srv_need(), and srv_next_frame().
|
static |
HPACK-decode the accumulated header block onto its stream.
Returns 0 on success, -1 on a connection error.
Definition at line 287 of file n_http2_server.c.
References H2BUF::data, N_H2_SERVER::dec, H2_STREAM::end_stream, N_H2_SERVER::err, N_H2_SERVER::hblock, N_H2_SERVER::hblock_end_stream, N_H2_SERVER::hblock_sid, H2_STREAM::hdrs, H2_STREAM::headers_done, H2BUF::len, N_H2_SRV_MAX_HEADERS, n_http2_hpack_decode(), n_http2_hpack_headers_free(), H2_STREAM::nhdrs, H2_STREAM::reset, and srv_stream_find().
Referenced by srv_apply_headers().
|
static |
handle one received frame.
Returns 0 on success, -1 on a connection error (s->err set).
< CONTINUATION
< HEADERS
< CONTINUATION
< DATA
< SETTINGS
< SETTINGS/PING: acknowledgement
< PING
< SETTINGS/PING: acknowledgement
< PING
< SETTINGS/PING: acknowledgement
< WINDOW_UPDATE
< RST_STREAM
< GOAWAY
< PUSH_PROMISE
< PRIORITY
Definition at line 512 of file n_http2_server.c.
References N_H2_SERVER::err, N_H2_FRAME::flags, N_H2_SERVER::goaway_recv, N_H2_SERVER::hblock_sid, N_H2_FRAME::length, LOG_DEBUG, N_H2_CONTINUATION, N_H2_DATA, N_H2_FLAG_ACK, N_H2_GOAWAY, N_H2_HEADERS, N_H2_PING, N_H2_PRIORITY, N_H2_PUSH_PROMISE, N_H2_RST_STREAM, N_H2_SETTINGS, N_H2_WINDOW_UPDATE, n_log, N_H2_FRAME::payload, H2_STREAM::reset, N_H2_SERVER::settings_acked, srv_apply_data(), srv_apply_headers(), srv_apply_settings(), srv_apply_window_update(), srv_send(), srv_stream_find(), N_H2_FRAME::stream_id, and N_H2_FRAME::type.
Referenced by n_http2_server_handshake(), and srv_pump_one().
|
static |
strip the pad-length prefix and priority fields of a HEADERS payload.
Returns 0 on success, -1 when the framing is inconsistent.
< DATA/HEADERS/PUSH_PROMISE: a pad-length prefix is present
< HEADERS: priority fields are present
Definition at line 328 of file n_http2_server.c.
References N_H2_FRAME::flags, N_H2_FRAME::length, N_H2_FLAG_PADDED, N_H2_FLAG_PRIORITY, and N_H2_FRAME::payload.
Referenced by srv_apply_headers().
|
static |
make sure at least n bytes are buffered.
Returns 1 on success, 0 on a short read at end of stream, -1 on an I/O error.
Definition at line 200 of file n_http2_server.c.
References H2BUF::len, N_H2_SERVER::rb, and srv_fill().
Referenced by n_http2_server_handshake().
|
static |
read the next complete frame into fr (aliasing the read buffer).
Returns 1 on a frame, 0 at end of stream, -1 on an error.
Definition at line 211 of file n_http2_server.c.
References H2BUF::data, N_H2_SERVER::err, H2BUF::len, n_http2_frame_parse(), N_H2_SERVER::rb, and srv_fill().
Referenced by n_http2_server_handshake(), and srv_pump_one().
|
static |
the lowest-numbered stream whose request is complete and undelivered
Definition at line 269 of file n_http2_server.c.
References H2_STREAM::delivered, H2_STREAM::end_stream, H2_STREAM::headers_done, H2_STREAM::id, H2_STREAM::in_use, N_H2_SRV_MAX_STREAMS, H2_STREAM::reset, and N_H2_SERVER::streams.
Referenced by n_http2_server_run().
|
static |
read and handle one frame.
Returns 1 on a handled frame, 0 at end of stream, -1 on an error.
Definition at line 564 of file n_http2_server.c.
References h2buf_shift(), N_H2_SERVER::rb, srv_handle_frame(), and srv_next_frame().
Referenced by n_http2_server_respond(), and n_http2_server_run().
|
static |
write one 6-byte SETTINGS entry (identifier then value) into out
Definition at line 168 of file n_http2_server.c.
Referenced by n_http2_server_handshake().
|
static |
write one frame (header then payload).
Returns 0 on success, -1 on a write failure (which also latches io_failed).
Definition at line 136 of file n_http2_server.c.
References N_H2_SERVER::err, N_H2_SERVER::io, N_H2_SERVER::io_failed, N_H2_FRAME_HEADER_LEN, n_http2_frame_build_header(), type(), and N_H2_SERVER::wr.
Referenced by n_http2_server_goaway(), n_http2_server_handshake(), n_http2_server_respond(), n_http2_server_rst_stream(), srv_apply_settings(), srv_handle_frame(), and srv_window_update().
|
static |
release a stream slot and everything it owns
Definition at line 257 of file n_http2_server.c.
References H2_STREAM::body, h2buf_free(), H2_STREAM::hdrs, H2_STREAM::in_use, n_http2_hpack_headers_free(), and H2_STREAM::nhdrs.
Referenced by n_http2_server_free(), and n_http2_server_run().
|
static |
the stream with this id, or NULL
Definition at line 232 of file n_http2_server.c.
References H2_STREAM::id, H2_STREAM::in_use, N_H2_SRV_MAX_STREAMS, and N_H2_SERVER::streams.
Referenced by n_http2_server_respond(), n_http2_server_run(), srv_apply_data(), srv_apply_headers(), srv_apply_window_update(), srv_finish_headers(), and srv_handle_frame().
|
static |
open a stream, or NULL when the table is full
Definition at line 241 of file n_http2_server.c.
References H2_STREAM::id, H2_STREAM::in_use, N_H2_SRV_MAX_STREAMS, N_H2_SERVER::peer_initial_win, H2_STREAM::send_win, and N_H2_SERVER::streams.
Referenced by srv_apply_headers().
|
static |
send a WINDOW_UPDATE for sid with the given increment
< WINDOW_UPDATE
Definition at line 156 of file n_http2_server.c.
References N_H2_WINDOW_UPDATE, and srv_send().
Referenced by n_http2_server_handshake(), and srv_apply_data().