From 955855e224baae1a7680c00c02e54e2af6cff9d4 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 23 May 2026 15:01:45 +0200 Subject: [PATCH 01/10] Apply webtransport patch from upstream for nghttp3 v1.15.0 --- .../nghttp3/lib/includes/nghttp3/nghttp3.h | 295 +++++ deps/ngtcp2/nghttp3/lib/nghttp3_conn.c | 1062 ++++++++++++++++- deps/ngtcp2/nghttp3/lib/nghttp3_conn.h | 39 +- deps/ngtcp2/nghttp3/lib/nghttp3_conv.c | 6 + deps/ngtcp2/nghttp3/lib/nghttp3_conv.h | 26 +- deps/ngtcp2/nghttp3/lib/nghttp3_err.c | 9 + deps/ngtcp2/nghttp3/lib/nghttp3_frame.c | 38 + deps/ngtcp2/nghttp3/lib/nghttp3_frame.h | 76 ++ deps/ngtcp2/nghttp3/lib/nghttp3_http.c | 5 + deps/ngtcp2/nghttp3/lib/nghttp3_http.h | 2 + deps/ngtcp2/nghttp3/lib/nghttp3_stream.c | 243 ++++ deps/ngtcp2/nghttp3/lib/nghttp3_stream.h | 50 + deps/ngtcp2/nghttp3/lib/nghttp3_wt.c | 227 ++++ deps/ngtcp2/nghttp3/lib/nghttp3_wt.h | 86 ++ deps/ngtcp2/ngtcp2.gyp | 1 + 15 files changed, 2105 insertions(+), 60 deletions(-) create mode 100644 deps/ngtcp2/nghttp3/lib/nghttp3_wt.c create mode 100644 deps/ngtcp2/nghttp3/lib/nghttp3_wt.h diff --git a/deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h b/deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h index c38f5e8dad4b26..bcf3bf2af0dba4 100644 --- a/deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h +++ b/deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h @@ -325,6 +325,28 @@ typedef uint64_t nghttp3_duration; * that might generating excessive load. */ #define NGHTTP3_ERR_H3_EXCESSIVE_LOAD -610 +/** + * @macro + * + * :macro:`NGHTTP3_ERR_H3_MESSAGE_ERROR` indicates that HTTP message + * was malformed. + */ +#define NGHTTP3_ERR_H3_MESSAGE_ERROR -611 +/** + * @macro + * + * :macro:`NGHTTP3_ERR_WT_SESSION_GONE` indicates that WebTransport + * session was terminated or rejected. + */ +#define NGHTTP3_ERR_WT_SESSION_GONE -612 +/** + * @macro + * + * :macro:`NGHTTP3_ERR_WT_BUFFERED_STREAM_REJECTED` indicates that + * buffering WebTransport data stream was rejected. + */ +#define NGHTTP3_ERR_WT_BUFFERED_STREAM_REJECTED -613 + /** * @macro * @@ -493,6 +515,39 @@ typedef uint64_t nghttp3_duration; * error code ``QPACK_DECODER_STREAM_ERROR``. */ #define NGHTTP3_QPACK_DECODER_STREAM_ERROR 0x0202 +/** + * @macro + * + * :macro:`NGHTTP3_WT_BUFFERED_STREAM_REJECTED` is WebTransport error + * code ``WT_BUFFERED_STREAM_REJECTED``. + */ +#define NGHTTP3_WT_BUFFERED_STREAM_REJECTED 0x3994BD84 +/** + * @macro + * + * :macro:`NGHTTP3_WT_SESSION_GONE` is WebTransport error code + * ``WT_SESSION_GONE``. + */ +#define NGHTTP3_WT_SESSION_GONE 0x170D7B68 +/** + * @macro + * + * :macro:`NGHTTP3_WT_ALPN_ERROR` is WebTransport error code + * ``WT_ALPN_ERROR``. + * + * https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-15 + */ +#define NGHTTP3_WT_ALPN_ERROR 0x0817B3DD +/** + * @macro + * + * :macro:`NGHTTP3_WT_REQUIREMENTS_NOT_MET` is WebTransport error code + * ``WT_REQUIREMENTS_NOT_MET``. + * + * https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-15 + */ + +#define NGHTTP3_WT_REQUIREMENTS_NOT_MET 0x212C0D48 /** * @functypedef @@ -1830,6 +1885,16 @@ typedef struct nghttp3_settings { * v1.13.0. */ nghttp3_qpack_indexing_strat qpack_indexing_strat; + /** + * :member:`wt_enabled`, if set to nonzero, enables WebTransport. + * + * https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-15 + * + * TODO For client, it might be better to always enable + * WebTransport. Only draft version of client needs to send + * SETTINGS_WT_ENABLED. + */ + uint8_t wt_enabled; } nghttp3_settings; #define NGHTTP3_PROTO_SETTINGS_V1 1 @@ -1868,6 +1933,12 @@ typedef struct nghttp3_proto_settings { * Datagrams (see :rfc:`9297`). */ uint8_t h3_datagram; + /** + * :member:`wt_enabled`, if set to nonzero, enables WebTransport. + * + * https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-15 + */ + uint8_t wt_enabled; } nghttp3_proto_settings; /** @@ -2167,6 +2238,28 @@ typedef int (*nghttp3_recv_settings2)(nghttp3_conn *conn, const nghttp3_proto_settings *settings, void *conn_user_data); +/** + * @functypedef + * + * :type:`nghttp3_recv_wt_data` is a callback function which is + * invoked when data is received on WebTransport data stream. + * |session_id| is the WebTransport session ID. |stream_id| is the + * stream ID of the WebTransport data stream. |data| points to the + * received data, and its length is |datalen|. + * + * The application is responsible for increasing flow control credit + * (say, increasing by |datalen| bytes). + * + * The implementation of this callback must return 0 if it succeeds. + * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the + * caller immediately. Any values other than 0 is treated as + * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`. + */ +typedef int (*nghttp3_recv_wt_data)(nghttp3_conn *conn, int64_t session_id, + int64_t stream_id, const uint8_t *data, + size_t datalen, void *conn_user_data, + void *stream_user_data); + #define NGHTTP3_CALLBACKS_V1 1 #define NGHTTP3_CALLBACKS_V2 2 #define NGHTTP3_CALLBACKS_V3 3 @@ -2297,6 +2390,11 @@ typedef struct nghttp3_callbacks { * v1.14.0. */ nghttp3_recv_settings2 recv_settings2; + /** + * :member:`recv_wt_data` is a callback function which is invoked + * when data on WebTransport data stream is received. + */ + nghttp3_recv_wt_data recv_wt_data; } nghttp3_callbacks; /** @@ -3145,6 +3243,176 @@ NGHTTP3_EXTERN int nghttp3_check_header_value(const uint8_t *value, size_t len); */ NGHTTP3_EXTERN int nghttp3_conn_is_drained(nghttp3_conn *conn); +/** + * @function + * + * `nghttp3_conn_is_drained2` returns nonzero if + * `nghttp3_conn_shutdown` has been called, and there is no active + * remote streams. This function is for server use only. + * + * This function has been available since v1.16.0. + */ +NGHTTP3_EXTERN int nghttp3_conn_is_drained2(const nghttp3_conn *conn); + +/** + * @function + * + * `nghttp3_conn_submit_wt_request` works like + * `nghttp3_conn_submit_request`, but it is specifically tailored for + * WebTransport session establishment. |nva| of length |nvlen| + * specifies HTTP request header fields. They must contain at least + * the following fields: + * + * - :method = "CONNECT" + * - :scheme = "https" + * - :protocol = "webtransport" + * - :authority + * - :path + * + * The application must also set the following settings: + * + * - :member:`nghttp3_settings.h3_datagram = 1 + * - :member:`nghttp3_settings.wt_enabled = 1 + * + * It also must send the following QUIC transport parameters: + * + * - max_datagram_frame_size > 0 + * - reset_stream_at + * + * The application should wait for SETTINGS frame from server and make + * sure that it satisfies server-side requirements for WebTransport. + * + * After receiving 2xx response from server, WebTransport session is + * established. `nghttp3_conn_open_wt_data_stream` is used to open + * WebTransport data streams. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * TBD + */ +NGHTTP3_EXTERN int nghttp3_conn_submit_wt_request(nghttp3_conn *conn, + int64_t stream_id, + const nghttp3_nv *nva, + size_t nvlen, + void *stream_user_data); + +/** + * @function + * + * `nghttp3_conn_submit_wt_response` works like + * `nghttp3_conn_submit_response`, but it is specifically tailored for + * WebTransport session establishment. |nva| of length |nvlen| + * specifies HTTP response header fields. It must contain 2xx status + * code in :status field. + * + * The application should make sure that the stream denoted by + * |stream_id| is a request stream that requests WebTransport session + * establishment. If this function is called inside + * :member:`nghttp3_callbacks.end_headers` callback, + * `nghttp3_conn_server_confirm_wt_session` is called internally, and + * it establishes WebTransport session. If this function is called + * outside of the callback, the application must call + * `nghttp3_conn_server_confirm_wt_session` after calling this + * function. + * + * If `nghttp3_conn_submit_response` is used against the WebTransport + * upgrade request, it means refusal of the request regardless of HTTP + * status code. The application is responsible to set non-2xx status + * code when `nghttp3_conn_submit_response` is used. If + * `nghttp3_conn_submit_response` is called from + * :member:`nghttp3_callbacks.end_headers` callback, + * :member:`nghttp3_callbacks.stop_sending` callback is automatically + * called. If `nghttp3_conn_submit_response` is called outside of the + * :member:`nghttp3_callbacks.end_headers` callback, + * :member:`nghttp3_callbacks.stop_sending` is not called + * automatically. The application should tell QUIC stack to send + * STOP_SENDING frame to this stream. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * TBD + */ +NGHTTP3_EXTERN int nghttp3_conn_submit_wt_response(nghttp3_conn *conn, + int64_t stream_id, + const nghttp3_nv *nva, + size_t nvlen); + +/** + * @function + * + * `nghttp3_conn_server_confirm_wt_session` establishes WebTransport + * session. This should be called after + * `nghttp3_conn_submit_wt_response` call if it is not called inside + * `nghttp3_callbacks.end_headers` callback. + * + * Only server can call this function. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * TBD + */ +NGHTTP3_EXTERN int nghttp3_conn_server_confirm_wt_session(nghttp3_conn *conn, + int64_t session_id, + nghttp3_tstamp ts); + +/** + * @function + * + * `nghttp3_conn_open_wt_data_stream` opens WebTransport data stream. + * |session_id| is the stream ID that established WebTransport + * session. |stream_id| is the stream ID to write data, and it can be + * both bidirectional and unidirectional. |dr| must not be NULL, and + * it must have non-NULL callback. + * + * This function can be also used to start writing to the + * bidirectional stream initiated by the remote endpoint. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * TBD + */ +NGHTTP3_EXTERN int nghttp3_conn_open_wt_data_stream( + nghttp3_conn *conn, int64_t session_id, int64_t stream_id, + const nghttp3_data_reader *dr, void *stream_user_data); + +/** + * @function + * + * `nghttp3_conn_close_wt_session` closes WebTransport session denoted + * by |session_id| which is the stream ID that established + * WebTransport session. |wt_error_code| is WebTransport error code. + * Upon calling this function, all existing WebTransport data streams + * are shutdown. |msg| of |msglen| bytes is the application error + * message, which is optional. |msglen| must be less than or equal to + * 1024. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * TBD + */ +NGHTTP3_EXTERN int nghttp3_conn_close_wt_session(nghttp3_conn *conn, + int64_t session_id, + uint32_t wt_error_code, + const uint8_t *msg, + size_t msglen); + +/** + * @function + * + * `nghttp3_conn_get_stream_wt_session_id` returns the WebTransport + * session ID of a stream denoted by |stream_id| if it is WebTransport + * data stream. If the stream is not found, it is not a WebTransport + * data stream, or it is unable to get session ID, this function + * returns -1. + */ +NGHTTP3_EXTERN int64_t nghttp3_conn_get_stream_wt_session_id( + const nghttp3_conn *conn, int64_t stream_id); + /** * @function * @@ -3229,6 +3497,33 @@ NGHTTP3_EXTERN const nghttp3_info *nghttp3_version(int least_version); */ NGHTTP3_EXTERN int nghttp3_err_is_fatal(int liberr); +/* + * `nghttp3_get_varint` reads variable-length unsigned integer from + * |p|, and stores it in the buffer pointed by |dest| in host byte + * order. It returns |p| plus the number of bytes read from |p|. + */ +NGHTTP3_EXTERN const uint8_t *nghttp3_get_varint(int64_t *dest, + const uint8_t *p); + +/* + * `nghttp3_get_varintlen` returns the required number of bytes to + * read variable-length integer starting at |p|. + */ +NGHTTP3_EXTERN size_t nghttp3_get_varintlen(const uint8_t *p); + +/* + * `nghttp3_put_varint` writes |n| in |p| using variable-length + * integer encoding. It returns the one beyond of the last written + * position. + */ +NGHTTP3_EXTERN uint8_t *nghttp3_put_varint(uint8_t *p, int64_t n); + +/* + * `nghttp3_put_varintlen` returns the required number of bytes to + * encode |n|. + */ +NGHTTP3_EXTERN size_t nghttp3_put_varintlen(int64_t n); + /* * Versioned function wrappers */ diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c b/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c index a305be2e96414d..d8edfd884cb2bd 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c @@ -36,6 +36,7 @@ #include "nghttp3_unreachable.h" #include "nghttp3_settings.h" #include "nghttp3_callbacks.h" +#include "nghttp3_wt.h" nghttp3_objalloc_def(chunk, nghttp3_chunk, oplent) @@ -50,6 +51,30 @@ static int conn_remote_stream_uni(nghttp3_conn *conn, int64_t stream_id) { return (stream_id & 0x03) == 0x03; } +static int conn_wt_enabled(const nghttp3_conn *conn) { + const nghttp3_settings *local_settings = &conn->local.settings; + const nghttp3_proto_settings *remote_settings = &conn->remote.settings; + + if (!local_settings->wt_enabled || !local_settings->h3_datagram) { + return 0; + } + + if (conn->server) { + return (!(conn->flags & NGHTTP3_CONN_FLAG_SETTINGS_RECVED) || + /* TODO client sends SETTINGS_WT_ENABLED for draft + versions only. But some client implementations do not + send it. For interop purpose, do not require this + remote setting for now. */ + (/* remote_settings->wt_enabled && */ remote_settings + ->h3_datagram)) && + local_settings->enable_connect_protocol; + } + + return remote_settings->wt_enabled && + remote_settings->enable_connect_protocol && + remote_settings->h3_datagram; +} + static int conn_call_begin_headers(nghttp3_conn *conn, nghttp3_stream *stream) { int rv; @@ -251,6 +276,47 @@ static int conn_call_end_origin(nghttp3_conn *conn) { return 0; } +static int conn_call_recv_data(nghttp3_conn *conn, const nghttp3_stream *stream, + const uint8_t *data, size_t datalen) { + int rv; + + if (!conn->callbacks.recv_data) { + return 0; + } + + rv = conn->callbacks.recv_data(conn, stream->node.id, data, datalen, + conn->user_data, stream->user_data); + if (rv != 0) { + return NGHTTP3_ERR_CALLBACK_FAILURE; + } + + return 0; +} + +static int conn_call_recv_wt_data(nghttp3_conn *conn, + const nghttp3_stream *stream, + const uint8_t *data, size_t datalen) { + nghttp3_wt_session *wt_session; + int rv; + + if (!conn->callbacks.recv_wt_data) { + return 0; + } + + wt_session = stream->wt.session; + + assert(wt_session); + + rv = conn->callbacks.recv_wt_data(conn, wt_session->session_id, + stream->node.id, data, datalen, + conn->user_data, stream->user_data); + if (rv != 0) { + return NGHTTP3_ERR_CALLBACK_FAILURE; + } + + return 0; +} + static int conn_glitch_ratelim_drain(nghttp3_conn *conn, uint64_t n, nghttp3_tstamp ts) { if (ts == UINT64_MAX) { @@ -401,11 +467,25 @@ int nghttp3_conn_server_new_versioned(nghttp3_conn **pconn, return 0; } +static void remove_wt_session_ref(nghttp3_wt_session *wt_session) { + nghttp3_stream *stream; + + for (stream = wt_session->head; stream; stream = stream->wt.next) { + assert(stream->wt.session == wt_session); + + stream->wt.session = NULL; + } +} + static int free_stream(void *data, void *ptr) { nghttp3_stream *stream = data; (void)ptr; + if (nghttp3_stream_wt_ctrl(stream)) { + remove_wt_session_ref(stream->wt.session); + } + nghttp3_stream_del(stream); return 0; @@ -501,6 +581,10 @@ nghttp3_ssize nghttp3_conn_read_stream2(nghttp3_conn *conn, int64_t stream_id, return rv; } + if (conn_wt_enabled(conn)) { + stream->flags |= NGHTTP3_STREAM_FLAG_MAYBE_WT_DATA; + } + if ((conn->flags & NGHTTP3_CONN_FLAG_GOAWAY_QUEUED) && conn->tx.goaway_id <= stream_id) { stream->rstate.state = NGHTTP3_REQ_STREAM_STATE_IGN_REST; @@ -527,7 +611,9 @@ nghttp3_ssize nghttp3_conn_read_stream2(nghttp3_conn *conn, int64_t stream_id, } stream->rx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL; - } else if (nghttp3_server_stream_uni(stream_id)) { + } else if (nghttp3_server_stream_uni(stream_id) || + (conn_wt_enabled(conn) && + nghttp3_server_stream_bidi(stream_id))) { if (srclen == 0 && fin) { return 0; } @@ -537,6 +623,10 @@ nghttp3_ssize nghttp3_conn_read_stream2(nghttp3_conn *conn, int64_t stream_id, return rv; } + if (!(stream_id & 0x2) && conn_wt_enabled(conn)) { + stream->flags |= NGHTTP3_STREAM_FLAG_MAYBE_WT_DATA; + } + stream->rx.hstate = NGHTTP3_HTTP_STATE_RESP_INITIAL; } else { /* client doesn't expect to receive new bidirectional stream or @@ -545,10 +635,12 @@ nghttp3_ssize nghttp3_conn_read_stream2(nghttp3_conn *conn, int64_t stream_id, } } else if (conn->server) { assert(nghttp3_client_stream_bidi(stream_id) || - nghttp3_client_stream_uni(stream_id)); + nghttp3_client_stream_uni(stream_id) || + (conn_wt_enabled(conn) && nghttp3_server_stream_bidi(stream_id))); } else { assert(nghttp3_client_stream_bidi(stream_id) || - nghttp3_server_stream_uni(stream_id)); + nghttp3_server_stream_uni(stream_id) || + (conn_wt_enabled(conn) && nghttp3_server_stream_bidi(stream_id))); } if (srclen == 0 && !fin) { @@ -613,6 +705,12 @@ static nghttp3_ssize conn_read_type(nghttp3_conn *conn, nghttp3_stream *stream, conn->flags |= NGHTTP3_CONN_FLAG_QPACK_DECODER_OPENED; stream->type = NGHTTP3_STREAM_TYPE_QPACK_DECODER; break; + case NGHTTP3_STREAM_TYPE_WT_STREAM: + if (!conn_wt_enabled(conn)) { + return NGHTTP3_ERR_H3_STREAM_CREATION_ERROR; + } + stream->type = NGHTTP3_STREAM_TYPE_WT_STREAM; + break; default: stream->type = NGHTTP3_STREAM_TYPE_UNKNOWN; break; @@ -705,6 +803,10 @@ nghttp3_ssize nghttp3_conn_read_uni(nghttp3_conn *conn, nghttp3_stream *stream, } nconsumed = nghttp3_conn_read_qpack_decoder(conn, src, srclen); break; + case NGHTTP3_STREAM_TYPE_WT_STREAM: + nconsumed = + nghttp3_conn_read_wt_stream_uni(conn, stream, src, srclen, fin, ts); + break; case NGHTTP3_STREAM_TYPE_UNKNOWN: nconsumed = (nghttp3_ssize)srclen; break; @@ -797,7 +899,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, case NGHTTP3_FRAME_SETTINGS: /* SETTINGS frame might be empty. */ if (rstate->left == 0) { - rv = conn_call_recv_settings(conn); + rv = nghttp3_conn_on_settings_received(conn); if (rv != 0) { return rv; } @@ -895,7 +997,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, case NGHTTP3_CTRL_STREAM_STATE_SETTINGS: for (;;) { if (rstate->left == 0) { - rv = conn_call_recv_settings(conn); + rv = nghttp3_conn_on_settings_received(conn); if (rv != 0) { return rv; } @@ -1013,7 +1115,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, break; } - rv = conn_call_recv_settings(conn); + rv = nghttp3_conn_on_settings_received(conn); if (rv != 0) { return rv; } @@ -1338,6 +1440,35 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, return (nghttp3_ssize)nconsumed; } +static int conn_unlink_wt_session(nghttp3_conn *conn, + nghttp3_stream *wt_ctrl_stream) { + nghttp3_wt_session *wt_session = wt_ctrl_stream->wt.session; + nghttp3_stream *stream, *next; + int rv; + (void)rv; + + for (stream = wt_session->head; stream;) { + next = stream->wt.next; + + assert(stream->wt.session); + + stream->wt.session = NULL; + stream->wt.prev = stream->wt.next = NULL; + + rv = nghttp3_conn_shutdown_wt_data_stream(conn, stream, + NGHTTP3_WT_SESSION_GONE); + if (rv != 0) { + return rv; + } + + stream = next; + } + + wt_session->head = NULL; + + return 0; +} + static int conn_delete_stream(nghttp3_conn *conn, nghttp3_stream *stream) { int bidi = nghttp3_client_stream_bidi(stream->node.id); int rv; @@ -1368,6 +1499,15 @@ static int conn_delete_stream(nghttp3_conn *conn, nghttp3_stream *stream) { } } + if (nghttp3_stream_wt_ctrl(stream)) { + rv = conn_unlink_wt_session(conn, stream); + if (rv != 0) { + return rv; + } + } else if (nghttp3_stream_wt_data(stream)) { + nghttp3_wt_session_remove_stream(stream->wt.session, stream); + } + if (conn->server && nghttp3_client_stream_bidi(stream->node.id)) { assert(conn->remote.bidi.num_streams > 0); @@ -1501,6 +1641,7 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, int rv; nghttp3_stream_read_state *rstate = &stream->rstate; nghttp3_varint_read_state *rvint = &rstate->rvint; + nghttp3_stream *wt_ctrl_stream; nghttp3_ssize nread; size_t nconsumed = 0; int busy = 0; @@ -1512,7 +1653,8 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, return (nghttp3_ssize)srclen; } - if (stream->flags & NGHTTP3_STREAM_FLAG_QPACK_DECODE_BLOCKED) { + if (stream->flags & (NGHTTP3_STREAM_FLAG_QPACK_DECODE_BLOCKED | + NGHTTP3_STREAM_FLAG_WT_SESSION_BLOCKED)) { *pnproc = 0; if (srclen == 0) { @@ -1621,6 +1763,42 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, } rstate->state = NGHTTP3_REQ_STREAM_STATE_HEADERS; + break; + case NGHTTP3_EXFR_WT_STREAM_BIDI: + if (!nghttp3_stream_wt_data(stream) && + !(stream->flags & NGHTTP3_STREAM_FLAG_MAYBE_WT_DATA)) { + return NGHTTP3_ERR_H3_FRAME_ERROR; + } + + stream->flags &= (uint16_t)~NGHTTP3_STREAM_FLAG_MAYBE_WT_DATA; + + if (conn->server) { + if (stream->rx.hstate != NGHTTP3_HTTP_STATE_REQ_INITIAL) { + return NGHTTP3_ERR_H3_FRAME_ERROR; + } + } else if (stream->rx.hstate != NGHTTP3_HTTP_STATE_RESP_INITIAL) { + return NGHTTP3_ERR_H3_FRAME_ERROR; + } + + /* rstate->left is Session ID */ + rv = nghttp3_conn_on_wt_stream(conn, stream, rstate->left); + if (rv != 0) { + if (rv != NGHTTP3_ERR_WT_SESSION_GONE) { + return rv; + } + + stream->rstate.state = NGHTTP3_REQ_STREAM_STATE_IGN_REST; + + rv = nghttp3_conn_abort_stream(conn, stream, NGHTTP3_WT_SESSION_GONE); + if (rv != 0) { + return rv; + } + + break; + } + + rstate->state = NGHTTP3_REQ_STREAM_STATE_BEFORE_WT_DATA; + break; case NGHTTP3_FRAME_PUSH_PROMISE: /* We do not support push */ case NGHTTP3_FRAME_CANCEL_PUSH: @@ -1640,6 +1818,8 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, return NGHTTP3_ERR_H3_EXCESSIVE_LOAD; } + stream->flags &= (uint16_t)~NGHTTP3_STREAM_FLAG_MAYBE_WT_DATA; + /* TODO Handle reserved frame type */ busy = 1; rstate->state = NGHTTP3_REQ_STREAM_STATE_IGN_FRAME; @@ -1648,11 +1828,29 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, break; case NGHTTP3_REQ_STREAM_STATE_DATA: len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); - rv = nghttp3_conn_on_data(conn, stream, p, len); - if (rv != 0) { - return rv; + nread = nghttp3_conn_on_data(conn, stream, p, len); + if (nread < 0) { + if (nread != NGHTTP3_ERR_WT_SESSION_GONE) { + return nread; + } + + rv = nghttp3_conn_shutdown_wt_session(conn, stream, + NGHTTP3_WT_SESSION_GONE); + if (rv != 0) { + return rv; + } + + /* Now that the stream is in + NGHTTP3_REQ_STREAM_STATE_IGN_REST, end_stream callback is + not called. */ + + /* Pretend that all stream data have been consumed */ + nconsumed += len; + + goto almost_done; } p += len; + nconsumed += (size_t)nread; rstate->left -= (int64_t)len; if (rstate->left) { @@ -1724,7 +1922,9 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, return rv; } } - /* fall through */ + + rv = conn_call_end_headers(conn, stream, p == end && fin); + break; case NGHTTP3_HTTP_STATE_RESP_HEADERS_BEGIN: rv = conn_call_end_headers(conn, stream, p == end && fin); break; @@ -1746,6 +1946,62 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, nghttp3_stream_read_state_reset(rstate); + if (conn->server) { + if (stream->rx.hstate == NGHTTP3_HTTP_STATE_REQ_HEADERS_END) { + if (stream->wt.session && (stream->wt.session->flags & + NGHTTP3_WT_SESSION_FLAG_RESP_SUBMITTED)) { + /* Server has submitted WebTransport session. */ + rv = nghttp3_conn_on_wt_session_confirmed(conn, stream, ts); + if (rv != 0) { + return rv; + } + } else if (stream->rx.http.flags & NGHTTP3_HTTP_FLAG_WEBTRANSPORT) { + if (stream->flags & NGHTTP3_STREAM_FLAG_RESP_SUBMITTED) { + /* Server refused WebTransport upgrade request */ + stream->rstate.state = NGHTTP3_REQ_STREAM_STATE_IGN_REST; + + rv = conn_call_stop_sending(conn, stream, NGHTTP3_H3_NO_ERROR); + if (rv != 0) { + return rv; + } + } else { + /* Server has not submitted response */ + stream->flags |= NGHTTP3_STREAM_FLAG_WT_SESSION_BLOCKED; + if (p != end) { + rv = nghttp3_stream_buffer_data(stream, p, (size_t)(end - p)); + if (rv != 0) { + return rv; + } + } + + *pnproc = (size_t)(p - src); + + return (nghttp3_ssize)nconsumed; + } + } + } + } else if (stream->rx.hstate == NGHTTP3_HTTP_STATE_RESP_HEADERS_END && + stream->wt.session) { + if (stream->rx.http.status_code / 100 == 2) { + rv = nghttp3_conn_on_wt_session_confirmed(conn, stream, ts); + if (rv != 0) { + return rv; + } + } else { + /* Server refused WebTransport negotiation. Reset the session + stream. This could be a redirect, but client is instructed + not to follow the redirect automatically. Most of the + case, we cannot do anything but just close the stream. */ + stream->rstate.state = NGHTTP3_REQ_STREAM_STATE_IGN_REST; + + rv = nghttp3_conn_abort_stream(conn, stream, + NGHTTP3_H3_REQUEST_CANCELLED); + if (rv != 0) { + return rv; + } + } + } + break; case NGHTTP3_REQ_STREAM_STATE_IGN_FRAME: len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); @@ -1759,6 +2015,40 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, nghttp3_stream_read_state_reset(rstate); break; + case NGHTTP3_REQ_STREAM_STATE_BEFORE_WT_DATA: + rstate->state = NGHTTP3_REQ_STREAM_STATE_WT_DATA; + + assert(stream->wt.session); + + wt_ctrl_stream = + nghttp3_conn_find_stream(conn, stream->wt.session->session_id); + + if (!(wt_ctrl_stream->wt.session->flags & + NGHTTP3_WT_SESSION_FLAG_CONFIRMED)) { + stream->flags |= NGHTTP3_STREAM_FLAG_WT_SESSION_BLOCKED; + + if (p != end) { + rv = nghttp3_stream_buffer_data(stream, p, (size_t)(end - p)); + if (rv != 0) { + return rv; + } + } + + *pnproc = (size_t)(p - src); + + return (nghttp3_ssize)nconsumed; + } + + break; + case NGHTTP3_REQ_STREAM_STATE_WT_DATA: + rv = conn_call_recv_wt_data(conn, stream, p, (size_t)(end - p)); + if (rv != 0) { + return rv; + } + + p = end; + + goto almost_done; case NGHTTP3_REQ_STREAM_STATE_IGN_REST: nconsumed += (size_t)(end - p); *pnproc = (size_t)(end - src); @@ -1778,10 +2068,16 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, if (rv != 0) { return rv; } + + /* Fall through */ + /* When a stream is closed without any data */ + case NGHTTP3_REQ_STREAM_STATE_BEFORE_WT_DATA: + case NGHTTP3_REQ_STREAM_STATE_WT_DATA: rv = conn_call_end_stream(conn, stream); if (rv != 0) { return rv; } + break; case NGHTTP3_REQ_STREAM_STATE_IGN_REST: break; @@ -1794,8 +2090,8 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, return (nghttp3_ssize)nconsumed; } -int nghttp3_conn_on_data(nghttp3_conn *conn, nghttp3_stream *stream, - const uint8_t *data, size_t datalen) { +nghttp3_ssize nghttp3_conn_on_data(nghttp3_conn *conn, nghttp3_stream *stream, + const uint8_t *data, size_t datalen) { int rv; rv = nghttp3_http_on_data_chunk(stream, datalen); @@ -1803,17 +2099,21 @@ int nghttp3_conn_on_data(nghttp3_conn *conn, nghttp3_stream *stream, return rv; } - if (!conn->callbacks.recv_data) { - return 0; + if (!stream->wt.session) { + return conn_call_recv_data(conn, stream, data, datalen); } - rv = conn->callbacks.recv_data(conn, stream->node.id, data, datalen, - conn->user_data, stream->user_data); + /* The stream data must be buffered until WebTransport session has + been confirmed. */ + assert(stream->wt.session->flags & NGHTTP3_WT_SESSION_FLAG_CONFIRMED); + + rv = nghttp3_wt_session_read_stream(stream->wt.session, data, datalen); if (rv != 0) { - return NGHTTP3_ERR_CALLBACK_FAILURE; + return rv; } - return 0; + /* WebTransport control stream has consumed all data */ + return (nghttp3_ssize)datalen; } static nghttp3_pq *conn_get_sched_pq(nghttp3_conn *conn, nghttp3_tnode *tnode) { @@ -2008,6 +2308,14 @@ int nghttp3_conn_on_settings_entry_received(nghttp3_conn *conn, dest->h3_datagram = (uint8_t)ent->value; break; + case NGHTTP3_SETTINGS_ID_WT_ENABLED: + /* compat for pre draft-15 */ + case NGHTTP3_SETTINGS_ID_WT_MAX_SESSIONS: + case NGHTTP3_SETTINGS_ID_WT_MAX_SESSIONS_DRAFT7: + /* compat for ancient draft */ + case NGHTTP3_SETTINGS_ID_ENABLE_WEBTRANSPORT_DRAFT2: + dest->wt_enabled = ent->value != 0; + break; case NGHTTP3_H2_SETTINGS_ID_ENABLE_PUSH: case NGHTTP3_H2_SETTINGS_ID_MAX_CONCURRENT_STREAMS: case NGHTTP3_H2_SETTINGS_ID_INITIAL_WINDOW_SIZE: @@ -2021,6 +2329,37 @@ int nghttp3_conn_on_settings_entry_received(nghttp3_conn *conn, return 0; } +static int abort_wt_session(void *data, void *ptr) { + nghttp3_conn *conn = ptr; + nghttp3_stream *stream = data; + + if (!nghttp3_stream_wt_ctrl(stream)) { + return 0; + } + + stream->rstate.state = NGHTTP3_REQ_STREAM_STATE_IGN_REST; + + return nghttp3_conn_abort_stream(conn, stream, + NGHTTP3_H3_GENERAL_PROTOCOL_ERROR); +} + +int nghttp3_conn_on_settings_received(nghttp3_conn *conn) { + int rv; + + conn->flags |= NGHTTP3_CONN_FLAG_SETTINGS_RECVED; + + rv = conn_call_recv_settings(conn); + if (rv != 0) { + return rv; + } + + if (!conn->local.settings.wt_enabled || conn_wt_enabled(conn)) { + return 0; + } + + return nghttp3_map_each(&conn->streams, abort_wt_session, conn); +} + static int conn_on_priority_update_stream(nghttp3_conn *conn, const nghttp3_frame_priority_update *fr) { @@ -2062,6 +2401,11 @@ conn_on_priority_update_stream(nghttp3_conn *conn, stream->node.pri = fr->pri; stream->flags |= NGHTTP3_STREAM_FLAG_PRIORITY_UPDATE_RECVED; + + if (conn_wt_enabled(conn)) { + stream->flags |= NGHTTP3_STREAM_FLAG_MAYBE_WT_DATA; + } + stream->rx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL; return 0; @@ -2330,7 +2674,7 @@ nghttp3_ssize nghttp3_conn_writev_stream(nghttp3_conn *conn, return ncnt; } - if (nghttp3_client_stream_bidi(stream->node.id) && + if (nghttp3_stream_schedulable(stream) && !nghttp3_stream_require_schedule(stream)) { nghttp3_conn_unschedule_stream(conn, stream); } @@ -2369,7 +2713,7 @@ int nghttp3_conn_add_write_offset(nghttp3_conn *conn, int64_t stream_id, stream->unscheduled_nwrite += n; - if (!nghttp3_client_stream_bidi(stream->node.id)) { + if (!nghttp3_stream_schedulable(stream)) { return 0; } @@ -2411,6 +2755,22 @@ int nghttp3_conn_update_ack_offset(nghttp3_conn *conn, int64_t stream_id, return nghttp3_stream_update_ack_offset(stream, offset); } +static nghttp3_ssize wt_session_read_data(nghttp3_conn *conn, int64_t stream_id, + nghttp3_vec *vec, size_t veccnt, + uint32_t *pflags, + void *conn_user_data, + void *stream_user_data) { + (void)conn; + (void)stream_id; + (void)vec; + (void)veccnt; + (void)pflags; + (void)conn_user_data; + (void)stream_user_data; + + return NGHTTP3_ERR_WOULDBLOCK; +} + static int conn_submit_headers_data(nghttp3_conn *conn, nghttp3_stream *stream, const nghttp3_nv *nva, size_t nvlen, const nghttp3_data_reader *dr) { @@ -2429,13 +2789,7 @@ static int conn_submit_headers_data(nghttp3_conn *conn, nghttp3_stream *stream, .nvlen = nvlen, }; - rv = nghttp3_stream_frq_add(stream, &fr); - if (rv != 0) { - nghttp3_nva_del(nnva, conn->mem); - return rv; - } - - if (dr) { + if (dr && dr->read_data != wt_session_read_data) { fr.data = (nghttp3_frame_data){ .type = NGHTTP3_FRAME_DATA, .dr = *dr, @@ -2447,6 +2801,13 @@ static int conn_submit_headers_data(nghttp3_conn *conn, nghttp3_stream *stream, } } + rv = nghttp3_stream_frq_add(stream, &fr); + if (rv != 0) { + nghttp3_nva_del(nnva, conn->mem); + return rv; + } + + if (nghttp3_stream_require_schedule(stream)) { return nghttp3_conn_schedule_stream(conn, stream); } @@ -2562,6 +2923,8 @@ int nghttp3_conn_submit_response(nghttp3_conn *conn, int64_t stream_id, stream->flags |= NGHTTP3_STREAM_FLAG_WRITE_END_STREAM; } + stream->flags |= NGHTTP3_STREAM_FLAG_RESP_SUBMITTED; + return conn_submit_headers_data(conn, stream, nva, nvlen, dr); } @@ -2639,14 +3002,27 @@ int nghttp3_conn_shutdown(nghttp3_conn *conn) { } int nghttp3_conn_reject_stream(nghttp3_conn *conn, nghttp3_stream *stream) { + return nghttp3_conn_abort_stream(conn, stream, NGHTTP3_H3_REQUEST_REJECTED); +} + +int nghttp3_conn_abort_stream(nghttp3_conn *conn, nghttp3_stream *stream, + uint64_t error_code) { int rv; + int remote_uni = conn_remote_stream_uni(conn, stream->node.id); + int bidi = !nghttp3_stream_uni(stream->node.id); - rv = conn_call_stop_sending(conn, stream, NGHTTP3_H3_REQUEST_REJECTED); - if (rv != 0) { - return rv; + if (remote_uni || bidi) { + rv = conn_call_stop_sending(conn, stream, error_code); + if (rv != 0) { + return rv; + } + } + + if (remote_uni) { + return 0; } - return conn_call_reset_stream(conn, stream, NGHTTP3_H3_REQUEST_REJECTED); + return conn_call_reset_stream(conn, stream, error_code); } void nghttp3_conn_block_stream(nghttp3_conn *conn, int64_t stream_id) { @@ -2688,7 +3064,7 @@ int nghttp3_conn_unblock_stream(nghttp3_conn *conn, int64_t stream_id) { stream->flags &= (uint16_t)~NGHTTP3_STREAM_FLAG_FC_BLOCKED; - if (nghttp3_client_stream_bidi(stream->node.id) && + if (nghttp3_stream_schedulable(stream) && nghttp3_stream_require_schedule(stream)) { return nghttp3_conn_ensure_stream_scheduled(conn, stream); } @@ -2717,7 +3093,7 @@ int nghttp3_conn_resume_stream(nghttp3_conn *conn, int64_t stream_id) { stream->flags &= (uint16_t)~NGHTTP3_STREAM_FLAG_READ_DATA_BLOCKED; - if (nghttp3_client_stream_bidi(stream->node.id) && + if (nghttp3_stream_schedulable(stream) && nghttp3_stream_require_schedule(stream)) { return nghttp3_conn_ensure_stream_scheduled(conn, stream); } @@ -2733,8 +3109,7 @@ int nghttp3_conn_close_stream(nghttp3_conn *conn, int64_t stream_id, return NGHTTP3_ERR_STREAM_NOT_FOUND; } - if (nghttp3_stream_uni(stream_id) && - stream->type != NGHTTP3_STREAM_TYPE_UNKNOWN) { + if (nghttp3_stream_critical(stream)) { return NGHTTP3_ERR_H3_CLOSED_CRITICAL_STREAM; } @@ -2762,6 +3137,13 @@ int nghttp3_conn_shutdown_stream_read(nghttp3_conn *conn, int64_t stream_id) { } stream->flags |= NGHTTP3_STREAM_FLAG_SHUT_RD; + + /* If stream is WebTransport data stream, do not send QPACK Stream + Cancellation. */ + if (nghttp3_stream_wt_data(stream) || + (stream->flags & NGHTTP3_STREAM_FLAG_WT_DATA)) { + return 0; + } } return nghttp3_qpack_decoder_cancel_stream(&conn->qdec, stream_id); @@ -2942,3 +3324,611 @@ int nghttp3_conn_is_drained(nghttp3_conn *conn) { nghttp3_stream_outq_write_done(conn->tx.ctrl) && nghttp3_ringbuf_len(&conn->tx.ctrl->frq) == 0; } + +int nghttp3_conn_submit_wt_request(nghttp3_conn *conn, int64_t stream_id, + const nghttp3_nv *nva, size_t nvlen, + void *stream_user_data) { + int rv; + nghttp3_stream *stream; + + if (!conn_wt_enabled(conn)) { + return NGHTTP3_ERR_INVALID_STATE; + } + + rv = nghttp3_conn_submit_request( + conn, stream_id, nva, nvlen, + &(nghttp3_data_reader){.read_data = wt_session_read_data}, + stream_user_data); + if (rv != 0) { + return rv; + } + + stream = nghttp3_conn_find_stream(conn, stream_id); + + assert(stream); + + return nghttp3_conn_open_wt_session(conn, stream); +} + +int nghttp3_conn_submit_wt_response(nghttp3_conn *conn, int64_t stream_id, + const nghttp3_nv *nva, size_t nvlen) { + int rv; + nghttp3_stream *stream; + + if (!conn_wt_enabled(conn)) { + return NGHTTP3_ERR_INVALID_STATE; + } + + rv = nghttp3_conn_submit_response( + conn, stream_id, nva, nvlen, + &(nghttp3_data_reader){.read_data = wt_session_read_data}); + if (rv != 0) { + return rv; + } + + stream = nghttp3_conn_find_stream(conn, stream_id); + + if (!stream->wt.session) { + rv = nghttp3_conn_open_wt_session(conn, stream); + if (rv != 0) { + return rv; + } + } + + stream->wt.session->flags |= NGHTTP3_WT_SESSION_FLAG_RESP_SUBMITTED; + + return 0; +} + +int nghttp3_conn_server_confirm_wt_session(nghttp3_conn *conn, + int64_t session_id, + nghttp3_tstamp ts) { + nghttp3_stream *wt_ctrl_stream; + + wt_ctrl_stream = nghttp3_conn_find_stream(conn, session_id); + if (!wt_ctrl_stream) { + return NGHTTP3_ERR_STREAM_NOT_FOUND; + } + + assert(wt_ctrl_stream->wt.session); + assert(wt_ctrl_stream->wt.session->flags & + NGHTTP3_WT_SESSION_FLAG_RESP_SUBMITTED); + + wt_ctrl_stream->flags &= (uint16_t)~NGHTTP3_STREAM_FLAG_WT_SESSION_BLOCKED; + + return nghttp3_conn_on_wt_session_confirmed(conn, wt_ctrl_stream, ts); +} + +int nghttp3_conn_open_wt_session(nghttp3_conn *conn, nghttp3_stream *stream) { + int rv; + + rv = nghttp3_wt_session_new(&stream->wt.session, stream->node.id, conn->mem); + if (rv != 0) { + return rv; + } + + return 0; +} + +int nghttp3_conn_open_wt_data_stream(nghttp3_conn *conn, int64_t session_id, + int64_t stream_id, + const nghttp3_data_reader *dr, + void *stream_user_data) { + nghttp3_stream *stream, *wt_ctrl_stream; + nghttp3_wt_session *wt_session; + nghttp3_frame *fr; + int64_t type; + int rv; + int remote_bidi = 0; + + if (conn->server) { + assert(nghttp3_client_stream_bidi(stream_id) || + nghttp3_server_stream_bidi(stream_id) || + nghttp3_server_stream_uni(stream_id)); + } else { + assert(nghttp3_client_stream_bidi(stream_id) || + nghttp3_server_stream_bidi(stream_id) || + nghttp3_client_stream_uni(stream_id)); + } + + /* TODO Check session flow control */ + + assert(dr); + + if (conn->flags & NGHTTP3_CONN_FLAG_GOAWAY_RECVED) { + return NGHTTP3_ERR_CONN_CLOSING; + } + + wt_ctrl_stream = nghttp3_conn_find_stream(conn, session_id); + if (!wt_ctrl_stream || !wt_ctrl_stream->wt.session) { + return NGHTTP3_ERR_INVALID_ARGUMENT; + } + + wt_session = wt_ctrl_stream->wt.session; + + stream = nghttp3_conn_find_stream(conn, stream_id); + if (stream) { + if (conn->server) { + assert(nghttp3_client_stream_bidi(stream_id)); + } else { + assert(nghttp3_server_stream_bidi(stream_id)); + } + + /* TODO verify that we do not start writing more than once. */ + + /* Normally, stream->wt.session is not NULL because we must + identify WT stream header first. The only exception is a + stream create by priority update on server side. But it must + be client initiated bidi stream, and we must wait for its WT + header. */ + if (!stream->wt.session) { + return NGHTTP3_ERR_INVALID_ARGUMENT; + } + + if (stream->flags & NGHTTP3_STREAM_FLAG_WRITE_END_STREAM) { + return NGHTTP3_ERR_INVALID_STATE; + } + + remote_bidi = 1; + + if (stream_user_data) { + stream->user_data = stream_user_data; + } + + if (conn->server) { + stream->flags |= NGHTTP3_STREAM_FLAG_SERVER_PRIORITY_SET; + } + + assert(!nghttp3_tnode_is_scheduled(&stream->node)); + } else { + if (conn->server) { + assert(nghttp3_server_stream_bidi(stream_id) || + nghttp3_server_stream_uni(stream_id)); + } else { + assert(nghttp3_client_stream_bidi(stream_id) || + nghttp3_client_stream_uni(stream_id)); + } + + rv = nghttp3_conn_create_stream(conn, &stream, stream_id); + if (rv != 0) { + return rv; + } + + nghttp3_wt_session_add_stream(wt_session, stream); + + if (conn->server) { + stream->rx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL; + } else { + stream->rx.hstate = NGHTTP3_HTTP_STATE_RESP_INITIAL; + } + + stream->user_data = stream_user_data; + + if (stream_id & 0x2) { + stream->flags |= NGHTTP3_STREAM_FLAG_SHUT_RD; + stream->type = NGHTTP3_STREAM_TYPE_WT_STREAM; + } + } + + stream->node.pri = (nghttp3_pri){ + .urgency = NGHTTP3_DEFAULT_URGENCY, + .inc = 1, + }; + + if (stream_id & 0x2) { + type = NGHTTP3_EXFR_WT_STREAM_UNI; + } else if (remote_bidi) { + type = NGHTTP3_EXFR_WT_STREAM_DATA; + } else { + type = NGHTTP3_EXFR_WT_STREAM_BIDI; + stream->rstate.state = NGHTTP3_REQ_STREAM_STATE_BEFORE_WT_DATA; + } + + fr->wt = (nghttp3_frame_ex_wt){ + .type = NGHTTP3_FRAME_EX_WT, + .fr.wt_stream = + { + .type = type, + .session_id = session_id, + .dr = *dr, + }, + }; + + rv = nghttp3_stream_frq_add(stream, &fr); + if (rv != 0) { + return rv; + } + + + + if (nghttp3_stream_require_schedule(stream)) { + return nghttp3_conn_ensure_stream_scheduled(conn, stream); + } + + return 0; +} + +int nghttp3_conn_close_wt_session(nghttp3_conn *conn, int64_t session_id, + uint32_t wt_error_code, const uint8_t *msg, + size_t msglen) { + nghttp3_stream *stream; + nghttp3_wt_session *wt_session; + nghttp3_frame *fr; + int rv; + + stream = nghttp3_conn_find_stream(conn, session_id); + if (stream == NULL) { + return NGHTTP3_ERR_STREAM_NOT_FOUND; + } + + if (!nghttp3_stream_wt_ctrl(stream)) { + return NGHTTP3_ERR_INVALID_ARGUMENT; + } + + if (stream->flags & NGHTTP3_STREAM_FLAG_WRITE_END_STREAM) { + return NGHTTP3_ERR_INVALID_STATE; + } + + stream->flags |= NGHTTP3_STREAM_FLAG_WRITE_END_STREAM; + + wt_session = stream->wt.session; + + assert(!wt_session->tx.error_msg.base); + + if (msglen) { + wt_session->tx.error_msg.base = nghttp3_mem_malloc(conn->mem, msglen); + if (!wt_session->tx.error_msg.base) { + return NGHTTP3_ERR_NOMEM; + } + + memcpy(wt_session->tx.error_msg.base, msg, msglen); + wt_session->tx.error_msg.len = msglen; + } + + fr->cpsl = (nghttp3_frame_ex_cpsl){ + .type = NGHTTP3_FRAME_EX_CPSL, + .fr.wt_close_session = + { + .type = NGHTTP3_EXFR_CPSL_WT_CLOSE_SESSION, + .error_code = wt_error_code, + .error_msg = wt_session->tx.error_msg, + }, + }; + + rv = nghttp3_stream_frq_add(stream, &fr); + if (rv != 0) { + return rv; + } + + + if (nghttp3_stream_require_schedule(stream)) { + rv = nghttp3_conn_schedule_stream(conn, stream); + if (rv != 0) { + return rv; + } + } + + rv = nghttp3_conn_shutdown_all_wt_data_streams(conn, stream, + NGHTTP3_WT_SESSION_GONE); + if (rv != 0) { + return rv; + } + + stream->rstate.state = NGHTTP3_REQ_STREAM_STATE_IGN_REST; + + return conn_call_stop_sending(conn, stream, NGHTTP3_WT_SESSION_GONE); +} + +int nghttp3_conn_on_wt_stream(nghttp3_conn *conn, nghttp3_stream *stream, + int64_t session_id) { + nghttp3_stream *wt_ctrl_stream; + nghttp3_wt_session *wt_session; + int rv; + + if (!nghttp3_client_stream_bidi(session_id)) { + return NGHTTP3_ERR_WT_BUFFERED_STREAM_REJECTED; + } + + if (stream->wt.session) { + assert(stream->wt.session->session_id != stream->node.id); + + if (stream->wt.session->session_id != session_id) { + return NGHTTP3_ERR_WT_BUFFERED_STREAM_REJECTED; + } + + return 0; + } + + wt_ctrl_stream = nghttp3_conn_find_stream(conn, session_id); + if (!wt_ctrl_stream) { + if (!conn->server) { + /* On client's perspective, if session stream is not found, we are + sure that session is gone. */ + return NGHTTP3_ERR_WT_SESSION_GONE; + } + + if (nghttp3_ord_stream_id(session_id) > + conn->remote.bidi.max_client_streams) { + return NGHTTP3_ERR_WT_BUFFERED_STREAM_REJECTED; + } + + if ((conn->flags & NGHTTP3_CONN_FLAG_GOAWAY_QUEUED) && + conn->tx.goaway_id <= session_id) { + return NGHTTP3_ERR_WT_BUFFERED_STREAM_REJECTED; + } + + rv = conn_bidi_idtr_open(conn, session_id); + if (rv != 0) { + if (nghttp3_err_is_fatal(rv)) { + return rv; + } + + return NGHTTP3_ERR_WT_SESSION_GONE; + } + + conn->rx.max_stream_id_bidi = + nghttp3_max_int64(conn->rx.max_stream_id_bidi, session_id); + rv = nghttp3_conn_create_stream(conn, &wt_ctrl_stream, session_id); + if (rv != 0) { + return rv; + } + + wt_ctrl_stream->rx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL; + } + + if (!wt_ctrl_stream->wt.session) { + rv = nghttp3_conn_open_wt_session(conn, wt_ctrl_stream); + if (rv != 0) { + return rv; + } + } + + wt_session = wt_ctrl_stream->wt.session; + + assert(wt_session); + + nghttp3_wt_session_add_stream(wt_session, stream); + + return 0; +} + +int nghttp3_conn_on_wt_session_confirmed(nghttp3_conn *conn, + nghttp3_stream *wt_ctrl_stream, + nghttp3_tstamp ts) { + nghttp3_stream *stream; + nghttp3_wt_session *wt_session = wt_ctrl_stream->wt.session; + int rv; + + wt_session->flags |= NGHTTP3_WT_SESSION_FLAG_CONFIRMED; + + /* TODO Is stream gone during iteration? */ + for (stream = wt_session->head; stream; stream = stream->wt.next) { + stream->flags &= (uint16_t)~NGHTTP3_STREAM_FLAG_WT_SESSION_BLOCKED; + + rv = nghttp3_conn_process_blocked_wt_stream_data(conn, stream, ts); + if (rv != 0) { + return rv; + } + } + + return nghttp3_conn_process_blocked_wt_stream_data(conn, wt_ctrl_stream, ts); +} + +nghttp3_ssize nghttp3_conn_read_wt_stream_uni(nghttp3_conn *conn, + nghttp3_stream *stream, + const uint8_t *src, size_t srclen, + int fin, nghttp3_tstamp ts) { + const uint8_t *p = src, *end = src ? src + srclen : src; + int rv; + nghttp3_stream_read_state *rstate = &stream->rstate; + nghttp3_varint_read_state *rvint = &rstate->rvint; + nghttp3_ssize nread; + size_t nconsumed = 0; + nghttp3_stream *wt_ctrl_stream; + (void)ts; + + if ((stream->flags & NGHTTP3_STREAM_FLAG_SHUT_RD)) { + return (nghttp3_ssize)srclen; + } + + if (srclen == 0) { + goto almost_done; + } + + if (stream->flags & NGHTTP3_STREAM_FLAG_WT_SESSION_BLOCKED) { + if (srclen == 0) { + return 0; + } + + rv = nghttp3_stream_buffer_data(stream, p, srclen); + if (rv != 0) { + return rv; + } + + return 0; + } + + switch (rstate->state) { + case NGHTTP3_WT_STREAM_STATE_SESSION_ID: + assert(end - p > 0); + nread = nghttp3_read_varint(rvint, p, end, fin); + if (nread < 0) { + return NGHTTP3_ERR_H3_FRAME_ERROR; + } + + p += nread; + nconsumed += (size_t)nread; + if (rvint->left) { + /* TODO What should we do if unidirectional stream is closed + before reading Session ID? */ + break; + } + + rstate->left = rvint->acc; + nghttp3_varint_read_state_reset(rvint); + + /* rstate->left is Session ID */ + rv = nghttp3_conn_on_wt_stream(conn, stream, rstate->left); + if (rv != 0) { + if (rv != NGHTTP3_ERR_WT_SESSION_GONE) { + return rv; + } + + stream->rstate.state = NGHTTP3_WT_STREAM_STATE_IGN_REST; + + rv = nghttp3_conn_abort_stream(conn, stream, NGHTTP3_WT_SESSION_GONE); + if (rv != 0) { + return rv; + } + + nconsumed += (size_t)(end - p); + + return (nghttp3_ssize)nconsumed; + } + + rstate->state = NGHTTP3_WT_STREAM_STATE_DATA; + + wt_ctrl_stream = + nghttp3_conn_find_stream(conn, stream->wt.session->session_id); + + if (!(wt_ctrl_stream->wt.session->flags & + NGHTTP3_WT_SESSION_FLAG_CONFIRMED)) { + stream->flags |= NGHTTP3_STREAM_FLAG_WT_SESSION_BLOCKED; + + if (p != end) { + rv = nghttp3_stream_buffer_data(stream, p, (size_t)(end - p)); + if (rv != 0) { + return rv; + } + } + + return (nghttp3_ssize)nconsumed; + } + + if (p == end) { + break; + } + + /* Fall through */ + case NGHTTP3_WT_STREAM_STATE_DATA: + rv = conn_call_recv_wt_data(conn, stream, p, (size_t)(end - p)); + if (rv != 0) { + return rv; + } + + break; + case NGHTTP3_WT_STREAM_STATE_IGN_REST: + nconsumed += (size_t)(end - p); + + return (nghttp3_ssize)nconsumed; + } + +almost_done: + if (fin) { + rv = conn_call_end_stream(conn, stream); + if (rv != 0) { + return rv; + } + } + + return (nghttp3_ssize)nconsumed; +} + +int nghttp3_conn_process_blocked_wt_stream_data(nghttp3_conn *conn, + nghttp3_stream *stream, + nghttp3_tstamp ts) { + nghttp3_buf *buf; + nghttp3_ssize nconsumed; + size_t nproc; + int rv; + size_t len; + + for (;;) { + len = nghttp3_ringbuf_len(&stream->inq); + if (len == 0) { + break; + } + + buf = nghttp3_ringbuf_get(&stream->inq, 0); + + if (nghttp3_stream_uni(stream->node.id)) { + nconsumed = nghttp3_conn_read_wt_stream_uni( + conn, stream, buf->pos, nghttp3_buf_len(buf), + len == 1 && (stream->flags & NGHTTP3_STREAM_FLAG_READ_EOF), ts); + } else { + nconsumed = nghttp3_conn_read_bidi( + conn, &nproc, stream, buf->pos, nghttp3_buf_len(buf), + len == 1 && (stream->flags & NGHTTP3_STREAM_FLAG_READ_EOF), ts); + } + + if (nconsumed < 0) { + return (int)nconsumed; + } + + rv = conn_call_deferred_consume(conn, stream, (size_t)nconsumed); + if (rv != 0) { + return rv; + } + + nghttp3_buf_free(buf, stream->mem); + nghttp3_ringbuf_pop_front(&stream->inq); + } + + return 0; +} + +int nghttp3_conn_shutdown_wt_session(nghttp3_conn *conn, + nghttp3_stream *wt_ctrl_stream, + uint64_t error_code) { + int rv; + + rv = + nghttp3_conn_shutdown_all_wt_data_streams(conn, wt_ctrl_stream, error_code); + if (rv != 0) { + return rv; + } + + wt_ctrl_stream->rstate.state = NGHTTP3_REQ_STREAM_STATE_IGN_REST; + + return nghttp3_conn_abort_stream(conn, wt_ctrl_stream, error_code); +} + +int nghttp3_conn_shutdown_all_wt_data_streams(nghttp3_conn *conn, + nghttp3_stream *wt_ctrl_stream, + uint64_t error_code) { + nghttp3_wt_session *wt_session = wt_ctrl_stream->wt.session; + nghttp3_stream *stream; + int rv; + + for (stream = wt_session->head; stream; stream = stream->wt.next) { + rv = nghttp3_conn_shutdown_wt_data_stream(conn, stream, error_code); + if (rv != 0) { + return rv; + } + } + + return 0; +} + +int nghttp3_conn_shutdown_wt_data_stream(nghttp3_conn *conn, + nghttp3_stream *stream, + uint64_t error_code) { + if (stream->node.id & 0x2) { + stream->rstate.state = NGHTTP3_WT_STREAM_STATE_IGN_REST; + } else { + stream->rstate.state = NGHTTP3_REQ_STREAM_STATE_IGN_REST; + } + + return nghttp3_conn_abort_stream(conn, stream, error_code); +} + +int64_t nghttp3_conn_get_stream_wt_session_id(const nghttp3_conn *conn, + int64_t stream_id) { + const nghttp3_stream *stream = nghttp3_conn_find_stream(conn, stream_id); + + if (!stream || !nghttp3_stream_wt_data(stream)) { + return -1; + } + + return stream->wt.session->session_id; +} diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_conn.h b/deps/ngtcp2/nghttp3/lib/nghttp3_conn.h index 4f7f68f777a9be..67367c397b83d5 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_conn.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_conn.h @@ -201,8 +201,8 @@ nghttp3_ssize nghttp3_conn_read_qpack_decoder(nghttp3_conn *conn, const uint8_t *src, size_t srclen); -int nghttp3_conn_on_data(nghttp3_conn *conn, nghttp3_stream *stream, - const uint8_t *data, size_t datalen); +nghttp3_ssize nghttp3_conn_on_data(nghttp3_conn *conn, nghttp3_stream *stream, + const uint8_t *data, size_t datalen); int nghttp3_conn_on_priority_update(nghttp3_conn *conn, const nghttp3_frame_priority_update *fr); @@ -215,6 +215,8 @@ nghttp3_ssize nghttp3_conn_on_headers(nghttp3_conn *conn, int nghttp3_conn_on_settings_entry_received(nghttp3_conn *conn, const nghttp3_frame_settings *fr); +int nghttp3_conn_on_settings_received(nghttp3_conn *conn); + int nghttp3_conn_qpack_blocked_streams_push(nghttp3_conn *conn, nghttp3_stream *stream); @@ -232,10 +234,43 @@ void nghttp3_conn_unschedule_stream(nghttp3_conn *conn, nghttp3_stream *stream); int nghttp3_conn_reject_stream(nghttp3_conn *conn, nghttp3_stream *stream); +int nghttp3_conn_abort_stream(nghttp3_conn *conn, nghttp3_stream *stream, + uint64_t error_code); + /* * nghttp3_conn_get_next_tx_stream returns next stream to send. It * returns NULL if there is no such stream. */ nghttp3_stream *nghttp3_conn_get_next_tx_stream(nghttp3_conn *conn); +int nghttp3_conn_open_wt_session(nghttp3_conn *conn, nghttp3_stream *stream); + +int nghttp3_conn_on_wt_stream(nghttp3_conn *conn, nghttp3_stream *stream, + int64_t session_id); + +nghttp3_ssize nghttp3_conn_read_wt_stream_uni(nghttp3_conn *conn, + nghttp3_stream *stream, + const uint8_t *src, size_t srclen, + int fin, nghttp3_tstamp ts); + +int nghttp3_conn_on_wt_session_confirmed(nghttp3_conn *conn, + nghttp3_stream *wt_ctrl_stream, + nghttp3_tstamp ts); + +int nghttp3_conn_process_blocked_wt_stream_data(nghttp3_conn *conn, + nghttp3_stream *stream, + nghttp3_tstamp ts); + +int nghttp3_conn_shutdown_wt_session(nghttp3_conn *conn, + nghttp3_stream *wt_ctrl_stream, + uint64_t error_code); + +int nghttp3_conn_shutdown_all_wt_data_streams(nghttp3_conn *conn, + nghttp3_stream *wt_ctrl_stream, + uint64_t error_code); + +int nghttp3_conn_shutdown_wt_data_stream(nghttp3_conn *conn, + nghttp3_stream *stream, + uint64_t error_code); + #endif /* !defined(NGHTTP3_CONN_H) */ diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_conv.c b/deps/ngtcp2/nghttp3/lib/nghttp3_conv.c index 3e14ffcd394b9b..bb2e65ce5cf2e7 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_conv.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_conv.c @@ -70,6 +70,12 @@ size_t nghttp3_get_varintlen(const uint8_t *p) { return (size_t)(1u << (*p >> 6)); } +const uint8_t *nghttp3_get_uint32be(uint32_t *dest, const uint8_t *p) { + memcpy(dest, p, sizeof(*dest)); + *dest = ntohl(*dest); + return p + sizeof(*dest); +} + uint8_t *nghttp3_put_uint64be(uint8_t *p, uint64_t n) { n = nghttp3_htonl64(n); return nghttp3_cpymem(p, (const uint8_t *)&n, sizeof(n)); diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_conv.h b/deps/ngtcp2/nghttp3/lib/nghttp3_conv.h index 8895fe8d3415d6..f9297994176194 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_conv.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_conv.h @@ -131,17 +131,11 @@ STIN uint16_t ntohs(uint16_t netshort) { #endif /* defined(WIN32) */ /* - * nghttp3_get_varint reads variable-length unsigned integer from |p|, - * and stores it in the buffer pointed by |dest| in host byte order. - * It returns |p| plus the number of bytes read from |p|. + * nghttp3_get_uint32be reads 4 bytes from |p| as 32 bits unsigned + * integer encoded as network byte order, and stores it in the buffer + * pointed by |dest| in host byte order. It returns |p| + 4. */ -const uint8_t *nghttp3_get_varint(int64_t *dest, const uint8_t *p); - -/* - * nghttp3_get_varintlen returns the required number of bytes to read - * variable-length integer starting at |p|. - */ -size_t nghttp3_get_varintlen(const uint8_t *p); +const uint8_t *nghttp3_get_uint32be(uint32_t *dest, const uint8_t *p); /* * nghttp3_put_uint64be writes |n| in host byte order in |p| in @@ -164,18 +158,6 @@ uint8_t *nghttp3_put_uint32be(uint8_t *p, uint32_t n); */ uint8_t *nghttp3_put_uint16be(uint8_t *p, uint16_t n); -/* - * nghttp3_put_varint writes |n| in |p| using variable-length integer - * encoding. It returns the one beyond of the last written position. - */ -uint8_t *nghttp3_put_varint(uint8_t *p, int64_t n); - -/* - * nghttp3_put_varintlen returns the required number of bytes to - * encode |n|. - */ -size_t nghttp3_put_varintlen(int64_t n); - /* * nghttp3_ord_stream_id returns the ordinal number of |stream_id|. */ diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_err.c b/deps/ngtcp2/nghttp3/lib/nghttp3_err.c index eff6ea6a63a2f7..e6603c00f041f5 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_err.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_err.c @@ -76,6 +76,10 @@ const char *nghttp3_strerror(int liberr) { return "ERR_H3_STREAM_CREATION_ERROR"; case NGHTTP3_ERR_H3_EXCESSIVE_LOAD: return "ERR_H3_EXCESSIVE_LOAD"; + case NGHTTP3_ERR_WT_SESSION_GONE: + return "ERR_WT_SESSION_GONE"; + case NGHTTP3_ERR_WT_BUFFERED_STREAM_REJECTED: + return "ERR_WT_BUFFERED_STREAM_REJECTED"; case NGHTTP3_ERR_NOMEM: return "ERR_NOMEM"; case NGHTTP3_ERR_CALLBACK_FAILURE: @@ -122,7 +126,12 @@ uint64_t nghttp3_err_infer_quic_app_error_code(int liberr) { return NGHTTP3_H3_EXCESSIVE_LOAD; case NGHTTP3_ERR_MALFORMED_HTTP_HEADER: case NGHTTP3_ERR_MALFORMED_HTTP_MESSAGING: + case NGHTTP3_ERR_H3_MESSAGE_ERROR: return NGHTTP3_H3_MESSAGE_ERROR; + case NGHTTP3_ERR_WT_SESSION_GONE: + return NGHTTP3_WT_SESSION_GONE; + case NGHTTP3_ERR_WT_BUFFERED_STREAM_REJECTED: + return NGHTTP3_WT_BUFFERED_STREAM_REJECTED; default: return NGHTTP3_H3_GENERAL_PROTOCOL_ERROR; } diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_frame.c b/deps/ngtcp2/nghttp3/lib/nghttp3_frame.c index da88b54f96de65..608574c4db351e 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_frame.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_frame.c @@ -131,6 +131,44 @@ size_t nghttp3_frame_write_origin_len(int64_t *ppayloadlen, nghttp3_put_varintlen((int64_t)payloadlen) + payloadlen; } +uint8_t *nghttp3_frame_write_wt_stream(uint8_t *p, + const nghttp3_exfr_wt_stream *fr) { + p = nghttp3_put_varint(p, fr->type); + return nghttp3_put_varint(p, fr->session_id); +} + +size_t nghttp3_frame_write_wt_stream_len(const nghttp3_exfr_wt_stream *fr) { + return nghttp3_put_varintlen(fr->type) + + nghttp3_put_varintlen(fr->session_id); +} + +uint8_t *nghttp3_frame_write_cpsl_wt_close_session( + uint8_t *p, const nghttp3_exfr_cpsl_wt_close_session *fr, + int64_t payloadlen) { + p = nghttp3_frame_write_hd(p, NGHTTP3_FRAME_DATA, payloadlen); + p = nghttp3_frame_write_hd(p, fr->type, sizeof(fr->error_code)); + p = nghttp3_put_uint32be(p, fr->error_code); + + if (fr->error_msg.len) { + p = nghttp3_cpymem(p, fr->error_msg.base, fr->error_msg.len); + } + + return p; +} + +size_t nghttp3_frame_write_cpsl_wt_close_session_len( + int64_t *ppayloadlen, const nghttp3_exfr_cpsl_wt_close_session *fr) { + size_t cpsl_payloadlen = sizeof(fr->error_code) + fr->error_msg.len; + size_t payloadlen = nghttp3_put_varintlen(fr->type) + + nghttp3_put_varintlen((int64_t)cpsl_payloadlen) + + cpsl_payloadlen; + + *ppayloadlen = (int64_t)payloadlen; + + return nghttp3_put_varintlen(NGHTTP3_FRAME_DATA) + + nghttp3_put_varintlen((int64_t)payloadlen) + payloadlen; +} + int nghttp3_nva_copy(nghttp3_nv **pnva, const nghttp3_nv *nva, size_t nvlen, const nghttp3_mem *mem) { size_t i; diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_frame.h b/deps/ngtcp2/nghttp3/lib/nghttp3_frame.h index a8b706a7a6af83..72f32bf00c4fdf 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_frame.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_frame.h @@ -46,6 +46,24 @@ #define NGHTTP3_FRAME_PRIORITY_UPDATE_PUSH_ID 0x0f0701 /* ORIGIN: https://datatracker.ietf.org/doc/html/rfc9412 */ #define NGHTTP3_FRAME_ORIGIN 0x0c +/* WebTransport extended frame type */ +#define NGHTTP3_FRAME_EX_WT 0x4000000000000001 +/* WT_STREAM: + https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-14 */ +#define NGHTTP3_EXFR_WT_STREAM_BIDI 0x41 +#define NGHTTP3_EXFR_WT_STREAM_UNI 0x54 +#define NGHTTP3_EXFR_WT_STREAM_DATA 0x00 + +/* HTTP Capsule extended frame type */ +#define NGHTTP3_FRAME_EX_CPSL 0x4000000000000002 +#define NGHTTP3_EXFR_CPSL_WT_CLOSE_SESSION 0x2843 +#define NGHTTP3_EXFR_CPSL_WT_DRAIN_SESSION 0x78AE +#define NGHTTP3_EXFR_CPSL_WT_MAX_STREAMS_BIDI 0x190B4D3F +#define NGHTTP3_EXFR_CPSL_WT_MAX_STREAMS_UNI 0x190B4D40 +#define NGHTTP3_EXFR_CPSL_WT_STREAMS_BLOCKED_BIDI 0x190B4D43 +#define NGHTTP3_EXFR_CPSL_WT_STREAMS_BLOCKED_UNI 0x190B4D44 +#define NGHTTP3_EXFR_CPSL_WT_MAX_DATA 0x190B4D3D +#define NGHTTP3_EXFR_CPSL_WT_DATA_BLOCKED 0x190B4D41 /* Frame types that are reserved for HTTP/2, and must not be used in HTTP/3. */ @@ -76,6 +94,14 @@ typedef struct nghttp3_frame_headers { #define NGHTTP3_SETTINGS_ID_QPACK_BLOCKED_STREAMS 0x07 #define NGHTTP3_SETTINGS_ID_ENABLE_CONNECT_PROTOCOL 0x08 #define NGHTTP3_SETTINGS_ID_H3_DATAGRAM 0x33 +/* https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-15 */ +#define NGHTTP3_SETTINGS_ID_WT_ENABLED 0x2C7CF000 +/* https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-14 */ +#define NGHTTP3_SETTINGS_ID_WT_MAX_SESSIONS 0x14E9CD29 +/* https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-07 */ +#define NGHTTP3_SETTINGS_ID_WT_MAX_SESSIONS_DRAFT7 0xC671706A +/* https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-02 */ +#define NGHTTP3_SETTINGS_ID_ENABLE_WEBTRANSPORT_DRAFT2 0x2B603742 #define NGHTTP3_H2_SETTINGS_ID_ENABLE_PUSH 0x2 #define NGHTTP3_H2_SETTINGS_ID_MAX_CONCURRENT_STREAMS 0x3 @@ -132,6 +158,42 @@ typedef struct nghttp3_frame_origin { nghttp3_vec origin_list; } nghttp3_frame_origin; +typedef struct nghttp3_exfr_hd { + int64_t type; +} nghttp3_exfr_hd; + +typedef struct nghttp3_exfr_wt_stream { + int64_t type; + int64_t session_id; + nghttp3_data_reader dr; +} nghttp3_exfr_wt_stream; + +typedef union nghttp3_exfr_wt { + nghttp3_exfr_hd hd; + nghttp3_exfr_wt_stream wt_stream; +} nghttp3_exfr_wt; + +typedef struct nghttp3_frame_ex_wt { + int64_t type; + nghttp3_exfr_wt fr; +} nghttp3_frame_ex_wt; + +typedef struct nghttp3_exfr_cpsl_wt_close_session { + int64_t type; + nghttp3_vec error_msg; + uint32_t error_code; +} nghttp3_exfr_cpsl_wt_close_session; + +typedef union nghttp3_exfr_cpsl { + nghttp3_exfr_hd hd; + nghttp3_exfr_cpsl_wt_close_session wt_close_session; +} nghttp3_exfr_cpsl; + +typedef struct nghttp3_frame_ex_cpsl { + int64_t type; + nghttp3_exfr_cpsl fr; +} nghttp3_frame_ex_cpsl; + typedef union nghttp3_frame { nghttp3_frame_hd hd; nghttp3_frame_data data; @@ -140,6 +202,8 @@ typedef union nghttp3_frame { nghttp3_frame_goaway goaway; nghttp3_frame_priority_update priority_update; nghttp3_frame_origin origin; + nghttp3_frame_ex_wt wt; + nghttp3_frame_ex_cpsl cpsl; } nghttp3_frame; /* @@ -233,6 +297,18 @@ uint8_t *nghttp3_frame_write_origin(uint8_t *dest, size_t nghttp3_frame_write_origin_len(int64_t *ppayloadlen, const nghttp3_frame_origin *fr); +uint8_t *nghttp3_frame_write_wt_stream(uint8_t *dest, + const nghttp3_exfr_wt_stream *fr); + +size_t nghttp3_frame_write_wt_stream_len(const nghttp3_exfr_wt_stream *fr); + +uint8_t *nghttp3_frame_write_cpsl_wt_close_session( + uint8_t *dest, const nghttp3_exfr_cpsl_wt_close_session *fr, + int64_t payloadlen); + +size_t nghttp3_frame_write_cpsl_wt_close_session_len( + int64_t *ppayloadlen, const nghttp3_exfr_cpsl_wt_close_session *fr); + /* * nghttp3_nva_copy copies name/value pairs from |nva|, which contains * |nvlen| pairs, to |*nva_ptr|, which is dynamically allocated so diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_http.c b/deps/ngtcp2/nghttp3/lib/nghttp3_http.c index 77449154ee2b98..41cfe74440a3d2 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_http.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_http.c @@ -375,6 +375,11 @@ static int http_request_on_header(nghttp3_http_state *http, !check_pseudo_header(http, nv, NGHTTP3_HTTP_FLAG__PROTOCOL)) { return NGHTTP3_ERR_MALFORMED_HTTP_HEADER; } + + if (lstrieq("webtransport", nv->value->base, nv->value->len)) { + http->flags |= NGHTTP3_HTTP_FLAG_WEBTRANSPORT; + } + break; case NGHTTP3_QPACK_TOKEN_HOST: if (!check_authority(nv->value->base, nv->value->len)) { diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_http.h b/deps/ngtcp2/nghttp3/lib/nghttp3_http.h index f0bfc69fbade75..89532b1c5805c0 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_http.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_http.h @@ -82,6 +82,8 @@ typedef struct nghttp3_http_state nghttp3_http_state; while parsing priority header field. */ #define NGHTTP3_HTTP_FLAG_BAD_PRIORITY 0x010000u +#define NGHTTP3_HTTP_FLAG_WEBTRANSPORT 0x020000U + /* * This function is called when HTTP header field |nv| received for * |http|. This function will validate |nv| against the current state diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_stream.c b/deps/ngtcp2/nghttp3/lib/nghttp3_stream.c index 6a6deaafd5b27a..202217a4c6f28b 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_stream.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_stream.c @@ -36,6 +36,7 @@ #include "nghttp3_http.h" #include "nghttp3_vec.h" #include "nghttp3_unreachable.h" +#include "nghttp3_wt.h" /* NGHTTP3_STREAM_MAX_COPY_THRES is the maximum size of buffer which makes a copy to outq. */ @@ -168,6 +169,10 @@ void nghttp3_stream_del(nghttp3_stream *stream) { delete_frq(&stream->frq, stream->mem); nghttp3_tnode_free(&stream->node); + if (nghttp3_stream_wt_ctrl(stream)) { + nghttp3_wt_session_del(stream->wt.session, stream->mem); + } + nghttp3_objalloc_stream_release(stream->stream_objalloc, stream); } @@ -298,6 +303,47 @@ int nghttp3_stream_fill_outq(nghttp3_stream *stream) { return rv; } + break; + case NGHTTP3_FRAME_EX_WT: + switch (fr->wt.fr.hd.type) { + case NGHTTP3_EXFR_WT_STREAM_BIDI: + case NGHTTP3_EXFR_WT_STREAM_UNI: + rv = nghttp3_stream_write_wt_stream(stream, &fr->wt.fr.wt_stream); + if (rv != 0) { + return rv; + } + + fr->wt.fr.wt_stream.type = NGHTTP3_EXFR_WT_STREAM_DATA; + + /* fall through */ + case NGHTTP3_EXFR_WT_STREAM_DATA: + rv = nghttp3_stream_write_wt_stream_data(stream, &data_eof, + &fr->wt.fr.wt_stream); + if (rv != 0) { + return rv; + } + + if ((stream->flags & NGHTTP3_STREAM_FLAG_READ_DATA_BLOCKED) || + !data_eof) { + return 0; + } + + break; + } + + break; + case NGHTTP3_FRAME_EX_CPSL: + switch (fr->cpsl.fr.hd.type) { + case NGHTTP3_EXFR_CPSL_WT_CLOSE_SESSION: + rv = nghttp3_stream_write_cpsl_wt_close_session( + stream, &fr->cpsl.fr.wt_close_session); + if (rv != 0) { + return rv; + } + + break; + } + break; default: /* TODO Not implemented */ @@ -376,6 +422,31 @@ int nghttp3_stream_write_settings(nghttp3_stream *stream, ++fr.niv; } + if (local_settings->wt_enabled) { + /* For client, only draft version sends SETTINGS_WT_ENABLED. */ + ents[fr.niv++] = (nghttp3_settings_entry){ + .id = NGHTTP3_SETTINGS_ID_WT_ENABLED, + .value = 1, + }; + + /* compat for pre draft-15 */ + ents[fr.niv++] = (nghttp3_settings_entry){ + .id = NGHTTP3_SETTINGS_ID_WT_MAX_SESSIONS, + .value = 1, + }; + + ents[fr.niv++] = (nghttp3_settings_entry){ + .id = NGHTTP3_SETTINGS_ID_WT_MAX_SESSIONS_DRAFT7, + .value = 1, + }; + + /* compat for ancient draft */ + ents[fr.niv++] = (nghttp3_settings_entry){ + .id = NGHTTP3_SETTINGS_ID_ENABLE_WEBTRANSPORT_DRAFT2, + .value = 1, + }; + } + len = nghttp3_frame_write_settings_len(&payloadlen, &fr); rv = nghttp3_stream_ensure_chunk(stream, len); @@ -482,6 +553,152 @@ int nghttp3_stream_write_origin(nghttp3_stream *stream, return nghttp3_stream_outq_add(stream, &tbuf); } +int nghttp3_stream_write_wt_stream(nghttp3_stream *stream, + const nghttp3_exfr_wt_stream *fr) { + size_t len; + int rv; + nghttp3_buf *chunk; + nghttp3_typed_buf tbuf; + + len = nghttp3_frame_write_wt_stream_len(fr); + + rv = nghttp3_stream_ensure_chunk(stream, len); + if (rv != 0) { + return rv; + } + + chunk = nghttp3_stream_get_chunk(stream); + nghttp3_typed_buf_shared_init(&tbuf, chunk); + + chunk->last = nghttp3_frame_write_wt_stream(chunk->last, fr); + + tbuf.buf.last = chunk->last; + + return nghttp3_stream_outq_add(stream, &tbuf); +} + +int nghttp3_stream_write_wt_stream_data(nghttp3_stream *stream, int *peof, + const nghttp3_exfr_wt_stream *fr) { + int rv; + nghttp3_typed_buf tbuf; + nghttp3_buf buf; + nghttp3_read_data_callback read_data = fr->dr.read_data; + nghttp3_conn *conn = stream->conn; + int64_t datalen; + uint32_t flags = 0; + nghttp3_vec vec[8]; + nghttp3_vec *v; + nghttp3_ssize sveccnt; + size_t i; + + assert(!(stream->flags & NGHTTP3_STREAM_FLAG_READ_DATA_BLOCKED)); + assert(read_data); + assert(conn); + + *peof = 0; + + sveccnt = read_data(conn, stream->node.id, vec, nghttp3_arraylen(vec), &flags, + conn->user_data, stream->user_data); + if (sveccnt < 0) { + if (sveccnt == NGHTTP3_ERR_WOULDBLOCK) { + stream->flags |= NGHTTP3_STREAM_FLAG_READ_DATA_BLOCKED; + return 0; + } + return NGHTTP3_ERR_CALLBACK_FAILURE; + } + + datalen = nghttp3_vec_len_varint(vec, (size_t)sveccnt); + if (datalen == -1) { + return NGHTTP3_ERR_STREAM_DATA_OVERFLOW; + } + + assert(datalen || flags & NGHTTP3_DATA_FLAG_EOF); + + if (flags & NGHTTP3_DATA_FLAG_EOF) { + *peof = 1; + + stream->flags |= NGHTTP3_STREAM_FLAG_WRITE_END_STREAM; + if (datalen == 0) { + if (nghttp3_stream_outq_write_done(stream)) { + /* If this is the last data and its is 0 length, we don't need + send data. We rely on the non-emptiness of outq to + schedule stream, so add empty tbuf to outq to just send + fin. */ + nghttp3_buf_init(&buf); + nghttp3_typed_buf_init(&tbuf, &buf, NGHTTP3_BUF_TYPE_PRIVATE); + return nghttp3_stream_outq_add(stream, &tbuf); + } + + /* We are going to send data, but nothing to send this time. */ + + return 0; + } + } + + assert(datalen); + + for (i = 0; i < (size_t)sveccnt; ++i) { + v = &vec[i]; + if (v->len == 0) { + continue; + } + nghttp3_buf_wrap_init(&buf, v->base, v->len); + buf.last = buf.end; + nghttp3_typed_buf_init(&tbuf, &buf, NGHTTP3_BUF_TYPE_ALIEN); + rv = nghttp3_stream_outq_add(stream, &tbuf); + if (rv != 0) { + return rv; + } + } + + return 0; +} + +int nghttp3_stream_write_cpsl_wt_close_session( + nghttp3_stream *stream, const nghttp3_exfr_cpsl_wt_close_session *fr) { + int rv; + nghttp3_buf *chunk; + nghttp3_buf buf; + nghttp3_typed_buf tbuf; + size_t cpsl_payloadlen = sizeof(fr->error_code) + fr->error_msg.len; + size_t fr_hdlen = + nghttp3_frame_write_hd_len(fr->type, (int64_t)cpsl_payloadlen); + int64_t payloadlen = (int64_t)(fr_hdlen + cpsl_payloadlen); + + rv = nghttp3_stream_ensure_chunk( + stream, nghttp3_frame_write_hd_len(NGHTTP3_FRAME_DATA, payloadlen) + + fr_hdlen + sizeof(fr->error_code)); + if (rv != 0) { + return rv; + } + + chunk = nghttp3_stream_get_chunk(stream); + nghttp3_typed_buf_shared_init(&tbuf, chunk); + + chunk->last = + nghttp3_frame_write_hd(chunk->last, NGHTTP3_FRAME_DATA, payloadlen); + chunk->last = + nghttp3_frame_write_hd(chunk->last, fr->type, (int64_t)cpsl_payloadlen); + chunk->last = nghttp3_put_uint32be(chunk->last, fr->error_code); + + tbuf.buf.last = chunk->last; + + rv = nghttp3_stream_outq_add(stream, &tbuf); + if (rv != 0) { + return rv; + } + + if (fr->error_msg.len == 0) { + return 0; + } + + nghttp3_buf_wrap_init(&buf, fr->error_msg.base, fr->error_msg.len); + buf.last = buf.end; + nghttp3_typed_buf_init(&tbuf, &buf, NGHTTP3_BUF_TYPE_ALIEN_NO_ACK); + + return nghttp3_stream_outq_add(stream, &tbuf); +} + int nghttp3_stream_write_headers(nghttp3_stream *stream, const nghttp3_frame_headers *fr) { nghttp3_conn *conn = stream->conn; @@ -852,6 +1069,11 @@ int nghttp3_stream_require_schedule(nghttp3_stream *stream) { !(stream->flags & NGHTTP3_STREAM_FLAG_READ_DATA_BLOCKED)); } +int nghttp3_stream_schedulable(const nghttp3_stream *stream) { + return !nghttp3_stream_uni(stream->node.id) || + stream->type == NGHTTP3_STREAM_TYPE_WT_STREAM; +} + size_t nghttp3_stream_writev(nghttp3_stream *stream, int *pfin, nghttp3_vec *vec, size_t veccnt) { nghttp3_ringbuf *outq = &stream->outq; @@ -1239,8 +1461,25 @@ int nghttp3_stream_empty_headers_allowed(nghttp3_stream *stream) { } } +int nghttp3_stream_critical(const nghttp3_stream *stream) { + return nghttp3_stream_uni(stream->node.id) && + (stream->type == NGHTTP3_STREAM_TYPE_CONTROL || + stream->type == NGHTTP3_STREAM_TYPE_QPACK_ENCODER || + stream->type == NGHTTP3_STREAM_TYPE_QPACK_DECODER); +} + int nghttp3_stream_uni(int64_t stream_id) { return (stream_id & 0x2) != 0; } +int nghttp3_stream_wt_ctrl(const nghttp3_stream *stream) { + return stream->wt.session && + stream->wt.session->session_id == stream->node.id; +} + +int nghttp3_stream_wt_data(const nghttp3_stream *stream) { + return stream->wt.session && + stream->wt.session->session_id != stream->node.id; +} + int nghttp3_client_stream_bidi(int64_t stream_id) { return (stream_id & 0x3) == 0; } @@ -1252,3 +1491,7 @@ int nghttp3_client_stream_uni(int64_t stream_id) { int nghttp3_server_stream_uni(int64_t stream_id) { return (stream_id & 0x3) == 0x3; } + +int nghttp3_server_stream_bidi(int64_t stream_id) { + return (stream_id & 0x3) == 0x1; +} diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_stream.h b/deps/ngtcp2/nghttp3/lib/nghttp3_stream.h index 20fa4212213f03..33db7d173d820f 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_stream.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_stream.h @@ -56,6 +56,7 @@ typedef uint64_t nghttp3_stream_type; #define NGHTTP3_STREAM_TYPE_PUSH 0x01 #define NGHTTP3_STREAM_TYPE_QPACK_ENCODER 0x02 #define NGHTTP3_STREAM_TYPE_QPACK_DECODER 0x03 +#define NGHTTP3_STREAM_TYPE_WT_STREAM 0x54 #define NGHTTP3_STREAM_TYPE_UNKNOWN UINT64_MAX typedef enum nghttp3_ctrl_stream_state { @@ -78,10 +79,19 @@ typedef enum nghttp3_req_stream_state { NGHTTP3_REQ_STREAM_STATE_FRAME_LENGTH, NGHTTP3_REQ_STREAM_STATE_DATA, NGHTTP3_REQ_STREAM_STATE_HEADERS, + NGHTTP3_REQ_STREAM_STATE_BEFORE_WT_DATA, + NGHTTP3_REQ_STREAM_STATE_WT_DATA, NGHTTP3_REQ_STREAM_STATE_IGN_FRAME, NGHTTP3_REQ_STREAM_STATE_IGN_REST, } nghttp3_req_stream_state; +/* stream state for WebTransport unidirectional data stream */ +typedef enum nghttp3_wt_stream_state { + NGHTTP3_WT_STREAM_STATE_SESSION_ID, + NGHTTP3_WT_STREAM_STATE_DATA, + NGHTTP3_WT_STREAM_STATE_IGN_REST, +} nghttp3_wt_stream_state; + typedef struct nghttp3_varint_read_state { int64_t acc; size_t left; @@ -95,6 +105,8 @@ typedef struct nghttp3_stream_read_state { int state; } nghttp3_stream_read_state; +typedef struct nghttp3_wt_session nghttp3_wt_session; + /* NGHTTP3_STREAM_FLAG_NONE indicates that no flag is set. */ #define NGHTTP3_STREAM_FLAG_NONE 0x0000u /* NGHTTP3_STREAM_FLAG_TYPE_IDENTIFIED is set when a unidirectional @@ -127,7 +139,20 @@ typedef struct nghttp3_stream_read_state { #define NGHTTP3_STREAM_FLAG_SERVER_PRIORITY_SET 0x0400u /* NGHTTP3_STREAM_FLAG_PRIORITY_UPDATE_RECVED indicates that server received PRIORITY_UPDATE frame for this stream. */ + #define NGHTTP3_STREAM_FLAG_PRIORITY_UPDATE_RECVED 0x0800u +/* NGHTTP3_STREAM_FLAG_MAYBE_WT_DATA indicates that the stream may be + WebTransport data stream. */ +#define NGHTTP3_STREAM_FLAG_MAYBE_WT_DATA 0x1000u +/* NGHTTP3_STREAM_FLAG_WT_DATA indicates that the stream is + WebTransport data stream. */ +#define NGHTTP3_STREAM_FLAG_WT_DATA 0x2000u +/* NGHTTP3_STREAM_FLAG_WT_SESSION_BLOCKED indicates that the stream is + blocked because WebTransport session has not been established. */ +#define NGHTTP3_STREAM_FLAG_WT_SESSION_BLOCKED 0x4000u +/* NGHTTP3_STREAM_FLAG_RESP_SUBMITTED indicates that HTTP/3 response + has been submitted via nghttp3_conn_submit_response. */ +#define NGHTTP3_STREAM_FLAG_RESP_SUBMITTED 0x8000u typedef enum nghttp3_stream_http_state { NGHTTP3_HTTP_STATE_NONE, @@ -237,6 +262,12 @@ struct nghttp3_stream { nghttp3_http_state http; } rx; + struct { + nghttp3_wt_session *session; + nghttp3_stream *prev; + nghttp3_stream *next; + } wt; + uint16_t flags; }; @@ -301,6 +332,15 @@ int nghttp3_stream_write_priority_update( int nghttp3_stream_write_origin(nghttp3_stream *stream, const nghttp3_frame_origin *fr); +int nghttp3_stream_write_wt_stream(nghttp3_stream *stream, + const nghttp3_exfr_wt_stream *fr); + +int nghttp3_stream_write_wt_stream_data(nghttp3_stream *stream, int *peof, + const nghttp3_exfr_wt_stream *fr); + +int nghttp3_stream_write_cpsl_wt_close_session( + nghttp3_stream *stream, const nghttp3_exfr_cpsl_wt_close_session *frent); + int nghttp3_stream_ensure_chunk(nghttp3_stream *stream, size_t need); nghttp3_buf *nghttp3_stream_get_chunk(nghttp3_stream *stream); @@ -335,6 +375,8 @@ int nghttp3_stream_is_active(nghttp3_stream *stream); */ int nghttp3_stream_require_schedule(nghttp3_stream *stream); +int nghttp3_stream_schedulable(const nghttp3_stream *stream); + int nghttp3_stream_buffer_data(nghttp3_stream *stream, const uint8_t *src, size_t srclen); @@ -349,6 +391,12 @@ int nghttp3_stream_transit_rx_http_state(nghttp3_stream *stream, int nghttp3_stream_empty_headers_allowed(nghttp3_stream *stream); +int nghttp3_stream_wt_ctrl(const nghttp3_stream *stream); + +int nghttp3_stream_wt_data(const nghttp3_stream *stream); + +int nghttp3_stream_critical(const nghttp3_stream *stream); + /* * nghttp3_stream_uni returns nonzero if stream identified by * |stream_id| is unidirectional. @@ -373,4 +421,6 @@ int nghttp3_client_stream_uni(int64_t stream_id); */ int nghttp3_server_stream_uni(int64_t stream_id); +int nghttp3_server_stream_bidi(int64_t stream_id); + #endif /* !defined(NGHTTP3_STREAM_H) */ diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_wt.c b/deps/ngtcp2/nghttp3/lib/nghttp3_wt.c new file mode 100644 index 00000000000000..cb7260797e945c --- /dev/null +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_wt.c @@ -0,0 +1,227 @@ +/* + * nghttp3 + * + * Copyright (c) 2025 nghttp3 contributors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include "nghttp3_wt.h" + +#include + +#include "nghttp3_mem.h" +#include "nghttp3_stream.h" + +int nghttp3_wt_session_new(nghttp3_wt_session **pwts, int64_t session_id, + const nghttp3_mem *mem) { + *pwts = nghttp3_mem_calloc(mem, 1, sizeof(**pwts)); + if (*pwts == NULL) { + return NGHTTP3_ERR_NOMEM; + } + + (*pwts)->session_id = session_id; + + return 0; +} + +void nghttp3_wt_session_del(nghttp3_wt_session *wts, const nghttp3_mem *mem) { + if (!wts) { + return; + } + + if (wts->tx.error_msg.base) { + nghttp3_mem_free(mem, wts->tx.error_msg.base); + } + + nghttp3_mem_free(mem, wts); +} + +void nghttp3_wt_session_add_stream(nghttp3_wt_session *wts, + nghttp3_stream *stream) { + assert(!stream->wt.session); + assert(!stream->wt.prev); + assert(!stream->wt.next); + + stream->wt.session = wts; + stream->flags |= NGHTTP3_STREAM_FLAG_WT_DATA; + + if (wts->head) { + stream->wt.next = wts->head; + wts->head->wt.prev = stream; + } + + wts->head = stream; +} + +void nghttp3_wt_session_remove_stream(nghttp3_wt_session *wts, + nghttp3_stream *stream) { + assert(stream->wt.session); + + if (stream->wt.prev) { + stream->wt.prev->wt.next = stream->wt.next; + } + + if (stream->wt.next) { + stream->wt.next->wt.prev = stream->wt.prev; + } + + if (wts->head == stream) { + wts->head = stream->wt.next; + } + + stream->wt.session = NULL; + stream->wt.prev = stream->wt.next = NULL; +} + +int nghttp3_wt_session_read_stream(nghttp3_wt_session *wts, const uint8_t *src, + size_t srclen) { + const uint8_t *p, *end; + nghttp3_wt_ctrl_read_state *rstate = &wts->rstate; + nghttp3_varint_read_state *rvint = &rstate->rvint; + nghttp3_ssize nread; + nghttp3_exfr_cpsl *cpsl = &rstate->cpsl; + size_t len; + size_t i; + + if (srclen == 0) { + return 0; + } + + p = src; + end = src + srclen; + + for (; p != end;) { + switch (rstate->state) { + case NGHTTP3_WT_CTRL_STREAM_STATE_TYPE: + assert(end - p > 0); + nread = nghttp3_read_varint(rvint, p, end, /* fin = */ 0); + + assert(nread > 0); + + p += nread; + if (rvint->left) { + return 0; + } + + rstate->cpsl.hd.type = rvint->acc; + + nghttp3_varint_read_state_reset(rvint); + rstate->state = NGHTTP3_WT_CTRL_STREAM_STATE_LENGTH; + if (p == end) { + return 0; + } + /* Fall through */ + case NGHTTP3_WT_CTRL_STREAM_STATE_LENGTH: + assert(end - p > 0); + nread = nghttp3_read_varint(rvint, p, end, /* fin = */ 0); + assert(nread > 0); + + p += nread; + if (rvint->left) { + return 0; + } + + rstate->left = rvint->acc; + nghttp3_varint_read_state_reset(rvint); + + switch (rstate->cpsl.hd.type) { + case NGHTTP3_EXFR_CPSL_WT_CLOSE_SESSION: + if (rstate->left < (int64_t)sizeof(uint32_t) || + rstate->left > + (int64_t)sizeof(uint32_t) + /* largest message size */ 1024) { + /* TODO Find better error code */ + return NGHTTP3_ERR_H3_MESSAGE_ERROR; + } + + rstate->field_left = sizeof(uint32_t); + rstate->state = + NGHTTP3_WT_CTRL_STREAM_STATE_WT_CLOSE_SESSION_ERROR_CODE; + + break; + default: + /* TODO Add rate limit after we implement all supported + capsules. */ + if (rstate->left == 0) { + nghttp3_wt_ctrl_read_state_reset(rstate); + break; + } + + rstate->state = NGHTTP3_WT_CTRL_STREAM_STATE_IGN; + } + + break; + case NGHTTP3_WT_CTRL_STREAM_STATE_WT_CLOSE_SESSION_ERROR_CODE: + len = (size_t)nghttp3_min_int64((int64_t)rstate->field_left, + (int64_t)(end - p)); + + for (i = 0; i < len; ++i) { + cpsl->wt_close_session.error_code <<= 8; + cpsl->wt_close_session.error_code += *p++; + } + + rstate->left -= (int64_t)len; + rstate->field_left -= len; + if (rstate->field_left) { + break; + } + + wts->error_code = cpsl->wt_close_session.error_code; + + if (rstate->left == 0) { + nghttp3_wt_ctrl_read_state_reset(rstate); + + return NGHTTP3_ERR_WT_SESSION_GONE; + } + + rstate->state = NGHTTP3_WT_CTRL_STREAM_STATE_WT_CLOSE_SESSION_ERROR_MSG; + + break; + case NGHTTP3_WT_CTRL_STREAM_STATE_WT_CLOSE_SESSION_ERROR_MSG: + len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + + rstate->left -= (int64_t)len; + if (rstate->left) { + break; + } + + nghttp3_wt_ctrl_read_state_reset(rstate); + + return NGHTTP3_ERR_WT_SESSION_GONE; + case NGHTTP3_WT_CTRL_STREAM_STATE_IGN: + len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + p += len; + rstate->left -= (int64_t)len; + + if (rstate->left) { + return 0; + } + + nghttp3_wt_ctrl_read_state_reset(rstate); + + break; + } + } + + return 0; +} + +void nghttp3_wt_ctrl_read_state_reset(nghttp3_wt_ctrl_read_state *rstate) { + *rstate = (nghttp3_wt_ctrl_read_state){0}; +} diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_wt.h b/deps/ngtcp2/nghttp3/lib/nghttp3_wt.h new file mode 100644 index 00000000000000..abc35f925055bf --- /dev/null +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_wt.h @@ -0,0 +1,86 @@ +/* + * nghttp3 + * + * Copyright (c) 2025 nghttp3 contributors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef NGHTTP3_WT_H +#define NGHTTP3_WT_H + +#ifdef HAVE_CONFIG_H +# include +#endif /* defined(HAVE_CONFIG_H) */ + +#include + +#include "nghttp3_stream.h" + +/* NGHTTP3_WT_SESSION_FLAG_CONFIRMED indicates that WebTransport + session has been established. */ +#define NGHTTP3_WT_SESSION_FLAG_CONFIRMED 0x1 +/* NGHTTP3_WT_SESSION_FLAG_RESP_SUBMITTED indicates that HTTP/3 + response has been submitted via nghttp3_conn_submit_wt_response. */ +#define NGHTTP3_WT_SESSION_FLAG_RESP_SUBMITTED 0x2 + +typedef enum nghttp3_wt_ctrl_stream_state { + NGHTTP3_WT_CTRL_STREAM_STATE_TYPE, + NGHTTP3_WT_CTRL_STREAM_STATE_LENGTH, + NGHTTP3_WT_CTRL_STREAM_STATE_WT_CLOSE_SESSION_ERROR_CODE, + NGHTTP3_WT_CTRL_STREAM_STATE_WT_CLOSE_SESSION_ERROR_MSG, + NGHTTP3_WT_CTRL_STREAM_STATE_IGN, +} nghttp3_wt_ctrl_stream_state; + +typedef struct nghttp3_wt_ctrl_read_state { + nghttp3_varint_read_state rvint; + nghttp3_exfr_cpsl cpsl; + int64_t left; + size_t field_left; + int state; +} nghttp3_wt_ctrl_read_state; + +typedef struct nghttp3_wt_session { + nghttp3_wt_ctrl_read_state rstate; + struct { + nghttp3_vec error_msg; + } tx; + int64_t session_id; + nghttp3_stream *head; + uint32_t error_code; + uint32_t flags; +} nghttp3_wt_session; + +void nghttp3_wt_session_add_stream(nghttp3_wt_session *wts, + nghttp3_stream *stream); + +void nghttp3_wt_session_remove_stream(nghttp3_wt_session *wts, + nghttp3_stream *stream); + +int nghttp3_wt_session_new(nghttp3_wt_session **pwts, int64_t stream_id, + const nghttp3_mem *mem); + +void nghttp3_wt_session_del(nghttp3_wt_session *wts, const nghttp3_mem *mem); + +int nghttp3_wt_session_read_stream(nghttp3_wt_session *wts, const uint8_t *data, + size_t datalen); + +void nghttp3_wt_ctrl_read_state_reset(nghttp3_wt_ctrl_read_state *rstate); + +#endif /* !defined(NGHTTP3_WT_H) */ diff --git a/deps/ngtcp2/ngtcp2.gyp b/deps/ngtcp2/ngtcp2.gyp index 7ad8997b0005e3..5822350291b03d 100644 --- a/deps/ngtcp2/ngtcp2.gyp +++ b/deps/ngtcp2/ngtcp2.gyp @@ -89,6 +89,7 @@ 'nghttp3/lib/nghttp3_unreachable.c', 'nghttp3/lib/nghttp3_vec.c', 'nghttp3/lib/nghttp3_version.c', + 'nghttp3/lib/nghttp3_wt.c', ], 'ngtcp2_test_server_sources': [ 'ngtcp2/examples/tls_server_session_ossl.cc', From 41d1ee61476f95477c5ced2ee39dad3a2d76e588 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 23 May 2026 17:49:04 +0200 Subject: [PATCH 02/10] Fix apply webtransport patch --- deps/ngtcp2/nghttp3/lib/nghttp3_conn.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c b/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c index d8edfd884cb2bd..cd94ebf9489ad1 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c @@ -2789,6 +2789,12 @@ static int conn_submit_headers_data(nghttp3_conn *conn, nghttp3_stream *stream, .nvlen = nvlen, }; + rv = nghttp3_stream_frq_add(stream, &fr); + if (rv != 0) { + nghttp3_nva_del(nnva, conn->mem); + return rv; + } + if (dr && dr->read_data != wt_session_read_data) { fr.data = (nghttp3_frame_data){ .type = NGHTTP3_FRAME_DATA, @@ -2801,11 +2807,6 @@ static int conn_submit_headers_data(nghttp3_conn *conn, nghttp3_stream *stream, } } - rv = nghttp3_stream_frq_add(stream, &fr); - if (rv != 0) { - nghttp3_nva_del(nnva, conn->mem); - return rv; - } if (nghttp3_stream_require_schedule(stream)) { From 280b03527549cee1fe12c6d6625c9f8f7ffe2ac1 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 30 May 2026 18:48:53 +0200 Subject: [PATCH 03/10] quic: ngtcp2 backport fix nghttp3_conn_open_wt_data_stream --- deps/ngtcp2/nghttp3/lib/nghttp3_conn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c b/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c index cd94ebf9489ad1..10309589961662 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c @@ -3417,7 +3417,7 @@ int nghttp3_conn_open_wt_data_stream(nghttp3_conn *conn, int64_t session_id, void *stream_user_data) { nghttp3_stream *stream, *wt_ctrl_stream; nghttp3_wt_session *wt_session; - nghttp3_frame *fr; + nghttp3_frame fr; int64_t type; int rv; int remote_bidi = 0; @@ -3525,7 +3525,7 @@ int nghttp3_conn_open_wt_data_stream(nghttp3_conn *conn, int64_t session_id, stream->rstate.state = NGHTTP3_REQ_STREAM_STATE_BEFORE_WT_DATA; } - fr->wt = (nghttp3_frame_ex_wt){ + fr.wt = (nghttp3_frame_ex_wt){ .type = NGHTTP3_FRAME_EX_WT, .fr.wt_stream = { From 14b0df0e2a01f0a6708e327f5d629e6eac3e89b9 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 6 Jun 2026 09:22:27 +0200 Subject: [PATCH 04/10] Use development version --- .../nghttp3/lib/includes/nghttp3/nghttp3.h | 375 +++- .../nghttp3/lib/includes/nghttp3/version.h | 4 +- deps/ngtcp2/nghttp3/lib/nghttp3_balloc.c | 12 +- deps/ngtcp2/nghttp3/lib/nghttp3_callbacks.c | 2 +- deps/ngtcp2/nghttp3/lib/nghttp3_conn.c | 384 ++-- deps/ngtcp2/nghttp3/lib/nghttp3_conn.h | 19 +- deps/ngtcp2/nghttp3/lib/nghttp3_conv.c | 39 +- deps/ngtcp2/nghttp3/lib/nghttp3_conv.h | 68 +- deps/ngtcp2/nghttp3/lib/nghttp3_frame.c | 94 +- deps/ngtcp2/nghttp3/lib/nghttp3_frame.h | 130 +- deps/ngtcp2/nghttp3/lib/nghttp3_gaptr.c | 10 +- deps/ngtcp2/nghttp3/lib/nghttp3_http.c | 152 +- deps/ngtcp2/nghttp3/lib/nghttp3_http.h | 40 +- deps/ngtcp2/nghttp3/lib/nghttp3_ksl.c | 31 +- deps/ngtcp2/nghttp3/lib/nghttp3_ksl.h | 31 +- deps/ngtcp2/nghttp3/lib/nghttp3_macro.h | 90 +- deps/ngtcp2/nghttp3/lib/nghttp3_map.c | 4 +- deps/ngtcp2/nghttp3/lib/nghttp3_objalloc.h | 4 +- deps/ngtcp2/nghttp3/lib/nghttp3_pq.c | 2 +- deps/ngtcp2/nghttp3/lib/nghttp3_qpack.c | 507 +++-- deps/ngtcp2/nghttp3/lib/nghttp3_qpack.h | 77 +- .../nghttp3/lib/nghttp3_qpack_huffman.c | 6 +- .../nghttp3/lib/nghttp3_qpack_huffman.h | 10 +- .../nghttp3/lib/nghttp3_qpack_huffman_data.c | 1972 ++++++++--------- deps/ngtcp2/nghttp3/lib/nghttp3_range.c | 4 +- deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c | 6 +- deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.h | 2 +- deps/ngtcp2/nghttp3/lib/nghttp3_str.c | 56 +- deps/ngtcp2/nghttp3/lib/nghttp3_stream.c | 93 +- deps/ngtcp2/nghttp3/lib/nghttp3_stream.h | 70 +- deps/ngtcp2/nghttp3/lib/nghttp3_tnode.c | 8 +- deps/ngtcp2/nghttp3/lib/nghttp3_tnode.h | 5 +- deps/ngtcp2/nghttp3/lib/nghttp3_vec.c | 6 +- deps/ngtcp2/nghttp3/lib/nghttp3_vec.h | 8 +- deps/ngtcp2/nghttp3/lib/nghttp3_wt.c | 18 +- deps/ngtcp2/nghttp3/lib/nghttp3_wt.h | 2 +- 36 files changed, 2351 insertions(+), 1990 deletions(-) diff --git a/deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h b/deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h index bcf3bf2af0dba4..8b29126393925b 100644 --- a/deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h +++ b/deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h @@ -86,8 +86,9 @@ typedef ptrdiff_t nghttp3_ssize; * * :type:`nghttp3_tstamp` is a timestamp with nanosecond resolution. * ``UINT64_MAX`` is an invalid value, and it is often used to - * indicate that no value is set. This type is available since - * v1.12.0. + * indicate that no value is set. + * + * .. version-added:: 1.12.0 */ typedef uint64_t nghttp3_tstamp; @@ -96,8 +97,9 @@ typedef uint64_t nghttp3_tstamp; * * :type:`nghttp3_duration` is a period of time in nanosecond * resolution. ``UINT64_MAX`` is an invalid value, and it is often - * used to indicate that no value is set. This type is available - * since v1.12.0. + * used to indicate that no value is set. + * + * .. version-added:: 1.12.0. */ typedef uint64_t nghttp3_duration; @@ -105,7 +107,9 @@ typedef uint64_t nghttp3_duration; * @macro * * :macro:`NGHTTP3_NANOSECONDS` is a count of tick which corresponds - * to 1 nanosecond. This macro is available since v1.12.0. + * to 1 nanosecond. + * + * .. version-added:: 1.12.0 */ #define NGHTTP3_NANOSECONDS ((nghttp3_duration)1ULL) @@ -113,7 +117,9 @@ typedef uint64_t nghttp3_duration; * @macro * * :macro:`NGHTTP3_MICROSECONDS` is a count of tick which corresponds - * to 1 microsecond. This macro is available since v1.12.0. + * to 1 microsecond. + * + * .. version-added:: 1.12.0 */ #define NGHTTP3_MICROSECONDS ((nghttp3_duration)(1000ULL * NGHTTP3_NANOSECONDS)) @@ -121,7 +127,9 @@ typedef uint64_t nghttp3_duration; * @macro * * :macro:`NGHTTP3_MILLISECONDS` is a count of tick which corresponds - * to 1 millisecond. This macro is available since v1.12.0. + * to 1 millisecond. + * + * .. version-added:: 1.12.0 */ #define NGHTTP3_MILLISECONDS \ ((nghttp3_duration)(1000ULL * NGHTTP3_MICROSECONDS)) @@ -130,7 +138,9 @@ typedef uint64_t nghttp3_duration; * @macro * * :macro:`NGHTTP3_SECONDS` is a count of tick which corresponds to 1 - * second. This macro is available since v1.12.0. + * second. + * + * .. version-added:: 1.12.0 */ #define NGHTTP3_SECONDS ((nghttp3_duration)(1000ULL * NGHTTP3_MILLISECONDS)) @@ -451,42 +461,42 @@ typedef uint64_t nghttp3_duration; * :macro:`NGHTTP3_H3_MISSING_SETTINGS` is HTTP/3 application error * code ``H3_MISSING_SETTINGS``. */ -#define NGHTTP3_H3_MISSING_SETTINGS 0x010a +#define NGHTTP3_H3_MISSING_SETTINGS 0x010A /** * @macro * * :macro:`NGHTTP3_H3_REQUEST_REJECTED` is HTTP/3 application error * code ``H3_REQUEST_REJECTED``. */ -#define NGHTTP3_H3_REQUEST_REJECTED 0x010b +#define NGHTTP3_H3_REQUEST_REJECTED 0x010B /** * @macro * * :macro:`NGHTTP3_H3_REQUEST_CANCELLED` is HTTP/3 application error * code ``H3_REQUEST_CANCELLED``. */ -#define NGHTTP3_H3_REQUEST_CANCELLED 0x010c +#define NGHTTP3_H3_REQUEST_CANCELLED 0x010C /** * @macro * * :macro:`NGHTTP3_H3_REQUEST_INCOMPLETE` is HTTP/3 application error * code ``H3_REQUEST_INCOMPLETE``. */ -#define NGHTTP3_H3_REQUEST_INCOMPLETE 0x010d +#define NGHTTP3_H3_REQUEST_INCOMPLETE 0x010D /** * @macro * * :macro:`NGHTTP3_H3_MESSAGE_ERROR` is HTTP/3 application error code * ``H3_MESSAGE_ERROR``. */ -#define NGHTTP3_H3_MESSAGE_ERROR 0x010e +#define NGHTTP3_H3_MESSAGE_ERROR 0x010E /** * @macro * * :macro:`NGHTTP3_H3_CONNECT_ERROR` is HTTP/3 application error code * ``H3_CONNECT_ERROR``. */ -#define NGHTTP3_H3_CONNECT_ERROR 0x010f +#define NGHTTP3_H3_CONNECT_ERROR 0x010F /** * @macro * @@ -808,7 +818,7 @@ NGHTTP3_EXTERN void nghttp3_buf_reset(nghttp3_buf *buf); * * :macro:`NGHTTP3_NV_FLAG_NONE` indicates no flag set. */ -#define NGHTTP3_NV_FLAG_NONE 0x00u +#define NGHTTP3_NV_FLAG_NONE 0x00U /** * @macro @@ -817,7 +827,7 @@ NGHTTP3_EXTERN void nghttp3_buf_reset(nghttp3_buf *buf); * pair must not be indexed. Other implementation calls this bit as * "sensitive". */ -#define NGHTTP3_NV_FLAG_NEVER_INDEX 0x01u +#define NGHTTP3_NV_FLAG_NEVER_INDEX 0x01U /** * @macro @@ -826,7 +836,7 @@ NGHTTP3_EXTERN void nghttp3_buf_reset(nghttp3_buf *buf); * If this flag is set, the library does not make a copy of field * name. This could improve performance. */ -#define NGHTTP3_NV_FLAG_NO_COPY_NAME 0x02u +#define NGHTTP3_NV_FLAG_NO_COPY_NAME 0x02U /** * @macro @@ -835,7 +845,7 @@ NGHTTP3_EXTERN void nghttp3_buf_reset(nghttp3_buf *buf); * application. If this flag is set, the library does not make a copy * of field value. This could improve performance. */ -#define NGHTTP3_NV_FLAG_NO_COPY_VALUE 0x04u +#define NGHTTP3_NV_FLAG_NO_COPY_VALUE 0x04U /** * @macro @@ -845,7 +855,7 @@ NGHTTP3_EXTERN void nghttp3_buf_reset(nghttp3_buf *buf); * a hint, and QPACK encoder might not encode the field in various * reasons. */ -#define NGHTTP3_NV_FLAG_TRY_INDEX 0x08u +#define NGHTTP3_NV_FLAG_TRY_INDEX 0x08U /** * @struct @@ -1211,8 +1221,9 @@ typedef struct nghttp3_qpack_nv { * * :type:`nghttp3_qpack_indexing_strat` defines the QPACK dynamic * table indexing strategies for fields not defined in - * :type:`nghttp3_qpack_token`. This type is available since v1.13.0. - + * :type:`nghttp3_qpack_token`. + * + * .. version-added:: 1.13.0 */ typedef enum nghttp3_qpack_indexing_strat { /** @@ -1220,14 +1231,16 @@ typedef enum nghttp3_qpack_indexing_strat { * fields not defined in :type:`nghttp3_qpack_token`. This is the * default strategy. You can still use * :macro:`NGHTTP3_NV_FLAG_TRY_INDEX` to index a particular field. - * This enum is available since v1.13.0. + * + * .. version-added:: 1.13.0 */ NGHTTP3_QPACK_INDEXING_STRAT_NONE, /** * :enum:`NGHTTP3_QPACK_INDEXING_STRAT_EAGER` indexes all fields not * defined in :type:`nghttp3_qpack_token`. Please note that QPACK - * encoder might not index the field in various reasons. This enum - * is available since v1.13.0. + * encoder might not index the field in various reasons. + * + * .. version-added:: 1.13.0 */ NGHTTP3_QPACK_INDEXING_STRAT_EAGER } nghttp3_qpack_indexing_strat; @@ -1288,7 +1301,7 @@ NGHTTP3_EXTERN int nghttp3_qpack_encoder_new(nghttp3_qpack_encoder **pencoder, * :macro:`NGHTTP3_ERR_NOMEM` * Out of memory. * - * This function is available since v1.11.0. + * .. version-added:: 1.11.0 */ NGHTTP3_EXTERN int nghttp3_qpack_encoder_new2(nghttp3_qpack_encoder **pencoder, size_t hard_max_dtable_capacity, @@ -1384,9 +1397,9 @@ nghttp3_qpack_encoder_set_max_blocked_streams(nghttp3_qpack_encoder *encoder, * @function * * `nghttp3_qpack_encoder_set_indexing_strat` sets the dynamic table - * indexing strategy |strat| to |encoder|. This function is available - * since v1.13.0. - + * indexing strategy |strat| to |encoder|. + * + * .. version-added:: 1.13.0 */ NGHTTP3_EXTERN void nghttp3_qpack_encoder_set_indexing_strat(nghttp3_qpack_encoder *encoder, @@ -1407,12 +1420,28 @@ nghttp3_qpack_encoder_ack_everything(nghttp3_qpack_encoder *encoder); /** * @function * + * .. warning:: + * + * .. version-deprecated:: 1.16.0 + * Use `nghttp3_qpack_encoder_get_num_blocked_streams2` instead. + * * `nghttp3_qpack_encoder_get_num_blocked_streams` returns the number * of streams which are potentially blocked at decoder side. */ NGHTTP3_EXTERN size_t nghttp3_qpack_encoder_get_num_blocked_streams(nghttp3_qpack_encoder *encoder); +/** + * @function + * + * `nghttp3_qpack_encoder_get_num_blocked_streams2` returns the number + * of streams which are potentially blocked at decoder side. + * + * .. version-added:: 1.16.0 + */ +NGHTTP3_EXTERN size_t nghttp3_qpack_encoder_get_num_blocked_streams2( + const nghttp3_qpack_encoder *encoder); + /** * @struct * @@ -1456,12 +1485,26 @@ nghttp3_qpack_stream_context_del(nghttp3_qpack_stream_context *sctx); /** * @function * + * .. warning:: + * + * .. version-deprecated:: 1.16.0 + * Use `nghttp3_qpack_stream_context_get_ricnt2` instead. + * * `nghttp3_qpack_stream_context_get_ricnt` returns required insert * count. */ NGHTTP3_EXTERN uint64_t nghttp3_qpack_stream_context_get_ricnt(nghttp3_qpack_stream_context *sctx); +/** + * @function + * + * `nghttp3_qpack_stream_context_get_ricnt2` returns required insert + * count. + */ +NGHTTP3_EXTERN uint64_t nghttp3_qpack_stream_context_get_ricnt2( + const nghttp3_qpack_stream_context *sctx); + /** * @function * @@ -1550,7 +1593,7 @@ nghttp3_qpack_decoder_get_icnt(const nghttp3_qpack_decoder *decoder); * * :macro:`NGHTTP3_QPACK_DECODE_FLAG_NONE` indicates that no flag set. */ -#define NGHTTP3_QPACK_DECODE_FLAG_NONE 0x00u +#define NGHTTP3_QPACK_DECODE_FLAG_NONE 0x00U /** * @macro @@ -1558,7 +1601,7 @@ nghttp3_qpack_decoder_get_icnt(const nghttp3_qpack_decoder *decoder); * :macro:`NGHTTP3_QPACK_DECODE_FLAG_EMIT` indicates that an HTTP * field is successfully decoded. */ -#define NGHTTP3_QPACK_DECODE_FLAG_EMIT 0x01u +#define NGHTTP3_QPACK_DECODE_FLAG_EMIT 0x01U /** * @macro @@ -1566,7 +1609,7 @@ nghttp3_qpack_decoder_get_icnt(const nghttp3_qpack_decoder *decoder); * :macro:`NGHTTP3_QPACK_DECODE_FLAG_FINAL` indicates that an entire * HTTP field section has been decoded. */ -#define NGHTTP3_QPACK_DECODE_FLAG_FINAL 0x02u +#define NGHTTP3_QPACK_DECODE_FLAG_FINAL 0x02U /** * @macro @@ -1574,7 +1617,7 @@ nghttp3_qpack_decoder_get_icnt(const nghttp3_qpack_decoder *decoder); * :macro:`NGHTTP3_QPACK_DECODE_FLAG_BLOCKED` indicates that decoding * has been blocked. */ -#define NGHTTP3_QPACK_DECODE_FLAG_BLOCKED 0x04u +#define NGHTTP3_QPACK_DECODE_FLAG_BLOCKED 0x04U /** * @function @@ -1634,8 +1677,8 @@ NGHTTP3_EXTERN nghttp3_ssize nghttp3_qpack_decoder_read_request( * * The caller must ensure that `nghttp3_buf_left(dbuf) * ` >= - * `nghttp3_qpack_decoder_get_decoder_streamlen(decoder) - * `. + * `nghttp3_qpack_decoder_get_decoder_streamlen2(decoder) + * `. */ NGHTTP3_EXTERN void nghttp3_qpack_decoder_write_decoder(nghttp3_qpack_decoder *decoder, @@ -1644,12 +1687,28 @@ nghttp3_qpack_decoder_write_decoder(nghttp3_qpack_decoder *decoder, /** * @function * + * .. warning:: + * + * .. version-deprecated:: 1.16.0 + * Use `nghttp3_qpack_decoder_get_decoder_streamlen2` instead. + * * `nghttp3_qpack_decoder_get_decoder_streamlen` returns the length of * decoder stream that is currently pending. */ NGHTTP3_EXTERN size_t nghttp3_qpack_decoder_get_decoder_streamlen(nghttp3_qpack_decoder *decoder); +/** + * @function + * + * `nghttp3_qpack_decoder_get_decoder_streamlen2` returns the length + * of decoder stream that is currently pending. + * + * .. version-added:: 1.16.0 + */ +NGHTTP3_EXTERN size_t nghttp3_qpack_decoder_get_decoder_streamlen2( + const nghttp3_qpack_decoder *decoder); + /** * @function * @@ -1769,7 +1828,7 @@ NGHTTP3_EXTERN void nghttp3_set_debug_vprintf_callback( * by a server when it initiates graceful shutdown of the connection * via `nghttp3_conn_submit_shutdown_notice`. */ -#define NGHTTP3_SHUTDOWN_NOTICE_STREAM_ID ((1ull << 62) - 4) +#define NGHTTP3_SHUTDOWN_NOTICE_STREAM_ID ((1ULL << 62) - 4) /** * @macro @@ -1779,7 +1838,7 @@ NGHTTP3_EXTERN void nghttp3_set_debug_vprintf_callback( * `nghttp3_conn_submit_shutdown_notice`. Note that libnghttp3 does * not implement HTTP/3 Server Push. */ -#define NGHTTP3_SHUTDOWN_NOTICE_PUSH_ID ((1ull << 62) - 1) +#define NGHTTP3_SHUTDOWN_NOTICE_PUSH_ID ((1ULL << 62) - 1) /** * @struct @@ -1845,7 +1904,8 @@ typedef struct nghttp3_settings { * Datagrams (see :rfc:`9297`). */ uint8_t h3_datagram; - /* The following fields have been added since NGHTTP3_SETTINGS_V2. */ + /* The following fields have been added since + NGHTTP3_SETTINGS_V2. */ /** * :member:`origin_list`, if set, must contain a serialized HTTP/3 * ORIGIN frame (see :rfc:`9412`) payload. The ORIGIN frame payload @@ -1857,10 +1917,13 @@ typedef struct nghttp3_settings { * until the :type:`nghttp3_conn` to which this field was passed is * freed by `nghttp3_conn_del`. The object pointed to by this field * is copied internally, and does not need to be kept alive. Only - * server uses this field. This field is available since v1.11.0. + * server uses this field. + * + * .. version-added:: 1.11.0 */ const nghttp3_vec *origin_list; - /* The following fields have been added since NGHTTP3_SETTINGS_V3. */ + /* The following fields have been added since + NGHTTP3_SETTINGS_V3. */ /** * :member:`glitch_ratelim_burst` is the maximum number of tokens * available to "glitch" rate limiter. "glitch" is a suspicious @@ -1868,21 +1931,27 @@ typedef struct nghttp3_settings { * tokens are consumed. If no tokens are available to consume, the * connection is closed. The rate of token generation is specified * by :member:`glitch_ratelim_rate`. This feature is enabled only - * when `nghttp3_conn_read_stream2` is used. This field has been - * available since v1.12.0. + * when `nghttp3_conn_read_stream2` is used. + * + * .. version-added:: 1.12.0 */ uint64_t glitch_ratelim_burst; /** * :member:`glitch_ratelim_rate` is the number of tokens generated * per second. See :member:`glitch_ratelim_burst` for "glitch" rate - * limiter. This field has been available since v1.12.0. + * limiter. + * + * .. version-added:: 1.12.0 */ uint64_t glitch_ratelim_rate; + /* The following fields have been added since + NGHTTP3_SETTINGS_V4. */ /** * :member:`qpack_indexing_strat` defines the QPACK dynamic table * indexing strategy for those fields that are not defined in - * :type:`nghttp3_qpack_token`. This field has been available since - * v1.13.0. + * :type:`nghttp3_qpack_token`. + * + * .. version-added:: 1.13.0 */ nghttp3_qpack_indexing_strat qpack_indexing_strat; /** @@ -1904,7 +1973,9 @@ typedef struct nghttp3_settings { * @struct * * :type:`nghttp3_proto_settings` contains HTTP/3 settings that this - * library can recognize. This field is available since v1.14.0. + * library can recognize. + * + * .. version-added:: 1.14.0 */ typedef struct nghttp3_proto_settings { /** @@ -2167,8 +2238,9 @@ typedef int (*nghttp3_shutdown)(nghttp3_conn *conn, int64_t id, * * .. warning:: * - * Deprecated since v1.14.0. Use :type:`nghttp3_recv_settings2` - * instead. New settings will not be notified with this callback. + * .. version-deprecated:: 1.14.0 + * Use :type:`nghttp3_recv_settings2` instead. New settings will + * not be notified with this callback. * * :type:`nghttp3_recv_settings` is a callback function which is * invoked when SETTINGS frame is received. |settings| is a received @@ -2231,8 +2303,9 @@ typedef void (*nghttp3_rand)(uint8_t *dest, size_t destlen); * The implementation of this callback must return 0 if it succeeds. * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the * caller immediately. Any values other than 0 is treated as - * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`. This callback is available - * since v1.14.0. + * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`. + * + * .. version-added:: 1.14.0 */ typedef int (*nghttp3_recv_settings2)(nghttp3_conn *conn, const nghttp3_proto_settings *settings, @@ -2260,6 +2333,26 @@ typedef int (*nghttp3_recv_wt_data)(nghttp3_conn *conn, int64_t session_id, size_t datalen, void *conn_user_data, void *stream_user_data); +/** + * @functypedef + * + * :type:`nghttp3_wt_data_stream_open` is a callback function which is + * invoked when a remote stream denoted by |stream_id| is identified + * as WebTransport data stream that belongs to WebTransport session + * identified by |session_id|. This callback function is called after + * WebTransport session is confirmed. + * + * The implementation of this callback must return 0 if it succeeds. + * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the + * caller immediately. Any values other than 0 is treated as + * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`. + */ +typedef int (*nghttp3_wt_data_stream_open)(nghttp3_conn *conn, + int64_t session_id, + int64_t stream_id, + void *conn_user_data, + void *stream_user_data); + #define NGHTTP3_CALLBACKS_V1 1 #define NGHTTP3_CALLBACKS_V2 2 #define NGHTTP3_CALLBACKS_V3 3 @@ -2355,24 +2448,27 @@ typedef struct nghttp3_callbacks { /** * .. warning:: * - * Deprecated since v1.14.0. Use :member:`recv_settings2` - * instead. + * .. version-deprecated:: 1.14.0 + * Use :member:`recv_settings2` instead. * * :member:`recv_settings` is a callback function which is invoked * when SETTINGS frame is received. */ nghttp3_recv_settings recv_settings; - /* The following fields have been added since NGHTTP3_CALLBACKS_V2. */ + /* The following fields have been added since + NGHTTP3_CALLBACKS_V2. */ /** * :member:`recv_origin` is a callback function which is invoked - * when a single origin in an ORIGIN frame is received. This field - * is available since v1.11.0. + * when a single origin in an ORIGIN frame is received. + * + * .. version-added:: 1.11.0 */ nghttp3_recv_origin recv_origin; /** * :member:`end_origin` is a callback function which is invoked when - * an ORIGIN frame has been completely processed. This field is - * available since v1.11.0. + * an ORIGIN frame has been completely processed. + * + * .. version-added:: 1.11.0 */ nghttp3_end_origin end_origin; /** @@ -2380,14 +2476,16 @@ typedef struct nghttp3_callbacks { * unpredictable data are needed. Although this field is optional * due to the backward compatibility, it is recommended to specify * this field to harden the runtime behavior against suspicious - * activities of a remote endpoint. This field is available since - * v1.11.0. + * activities of a remote endpoint. + * + * .. version-added:: 1.11.0 */ nghttp3_rand rand; /** * :member:`recv_settings2` is a callback function which is invoked - * when SETTINGS frame is received. This field is available since - * v1.14.0. + * when SETTINGS frame is received. + * + * .. version-added:: 1.14.0 */ nghttp3_recv_settings2 recv_settings2; /** @@ -2395,6 +2493,12 @@ typedef struct nghttp3_callbacks { * when data on WebTransport data stream is received. */ nghttp3_recv_wt_data recv_wt_data; + /** + * :member:`wt_data_stream_open` is a callback function which is + * invoked when a remote stream is identified as WebTransport data + * stream. + */ + nghttp3_wt_data_stream_open wt_data_stream_open; } nghttp3_callbacks; /** @@ -2404,7 +2508,7 @@ typedef struct nghttp3_callbacks { * values. * * - :member:`max_field_section_size - * ` = :expr:`((1ull << 62) - 1)` + * ` = :expr:`((1ULL << 62) - 1)` * - :member:`qpack_max_dtable_capacity * ` = 0 * - :member:`qpack_encoder_max_dtable_capacity @@ -2515,8 +2619,8 @@ NGHTTP3_EXTERN int nghttp3_conn_bind_qpack_streams(nghttp3_conn *conn, * * .. warning:: * - * Deprecated since v1.12.0. Use `nghttp3_conn_read_stream2` - * instead. + * .. version-deprecated:: 1.12.0 + * Use `nghttp3_conn_read_stream2` instead. * * `nghttp3_conn_read_stream` reads data |src| of length |srclen| on * stream identified by |stream_id|. It returns the number of bytes @@ -2574,7 +2678,7 @@ NGHTTP3_EXTERN nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn, * be closed. Calling nghttp3 API other than `nghttp3_conn_del` * causes undefined behavior. * - * This function is available since v1.12.0. + * .. version-added:: 1.12.0 */ NGHTTP3_EXTERN nghttp3_ssize nghttp3_conn_read_stream2(nghttp3_conn *conn, int64_t stream_id, @@ -2722,6 +2826,11 @@ NGHTTP3_EXTERN int nghttp3_conn_unblock_stream(nghttp3_conn *conn, /** * @function * + * .. warning:: + * + * .. version-deprecated:: 1.16.0 + * Use `nghttp3_conn_is_stream_writable2` instead. + * * `nghttp3_conn_is_stream_writable` returns nonzero if a stream * identified by |stream_id| is writable. It is not writable if: * @@ -2739,6 +2848,28 @@ NGHTTP3_EXTERN int nghttp3_conn_unblock_stream(nghttp3_conn *conn, NGHTTP3_EXTERN int nghttp3_conn_is_stream_writable(nghttp3_conn *conn, int64_t stream_id); +/** + * @function + * + * `nghttp3_conn_is_stream_writable2` returns nonzero if a stream + * identified by |stream_id| is writable. It is not writable if: + * + * - the stream does not exist; or, + * - the stream is closed (e.g., `nghttp3_conn_close_stream` is + * called); or, + * - the stream is QUIC flow control blocked (e.g., + * `nghttp3_conn_block_stream` is called); or, + * - the stream is input data blocked (e.g., + * :macro:`NGHTTP3_ERR_WOULDBLOCK` is returned from + * :type:`nghttp3_read_data_callback`); or, + * - the stream is half-closed local (e.g., + * `nghttp3_conn_shutdown_stream_write` is called). + * + * .. version-added:: 1.16.0 + */ +NGHTTP3_EXTERN int nghttp3_conn_is_stream_writable2(const nghttp3_conn *conn, + int64_t stream_id); + /** * @function * @@ -2827,7 +2958,7 @@ NGHTTP3_EXTERN int nghttp3_conn_close_stream(nghttp3_conn *conn, * * :macro:`NGHTTP3_DATA_FLAG_NONE` indicates no flag set. */ -#define NGHTTP3_DATA_FLAG_NONE 0x00u +#define NGHTTP3_DATA_FLAG_NONE 0x00U /** * @macro @@ -2837,7 +2968,7 @@ NGHTTP3_EXTERN int nghttp3_conn_close_stream(nghttp3_conn *conn, * that sending side of stream is closed unless * :macro:`NGHTTP3_DATA_FLAG_NO_END_STREAM` is given at the same time. */ -#define NGHTTP3_DATA_FLAG_EOF 0x01u +#define NGHTTP3_DATA_FLAG_EOF 0x01U /** * @macro @@ -2849,7 +2980,7 @@ NGHTTP3_EXTERN int nghttp3_conn_close_stream(nghttp3_conn *conn, * has been called, regardless of this flag, the submitted trailer * fields are sent. */ -#define NGHTTP3_DATA_FLAG_NO_END_STREAM 0x02u +#define NGHTTP3_DATA_FLAG_NO_END_STREAM 0x02U /** * @function @@ -3062,6 +3193,29 @@ NGHTTP3_EXTERN int nghttp3_conn_set_stream_user_data(nghttp3_conn *conn, /** * @function * + * `nghttp3_conn_get_stream_user_data` returns the user data + * associated to the stream identified by |stream_id|. If no data is + * associated or the stream is not found, this function returns NULL. + * + * The user data can be associated to the stream by the following + * functions: + * + * - `nghttp3_conn_set_stream_user_data` + * - `nghttp3_conn_submit_request` + * + * .. version-added:: 1.16.0 + */ +NGHTTP3_EXTERN void *nghttp3_conn_get_stream_user_data(const nghttp3_conn *conn, + int64_t stream_id); + +/** + * @function + * + * .. warning:: + * + * .. version-deprecated:: 1.16.0 + * Use `nghttp3_conn_get_frame_payload_left2` instead. + * * `nghttp3_conn_get_frame_payload_left` returns the number of bytes * left to read current frame payload for a stream denoted by * |stream_id|. If no such stream is found, or |stream_id| identifies @@ -3071,6 +3225,20 @@ NGHTTP3_EXTERN int nghttp3_conn_set_stream_user_data(nghttp3_conn *conn, NGHTTP3_EXTERN uint64_t nghttp3_conn_get_frame_payload_left(nghttp3_conn *conn, int64_t stream_id); +/** + * @function + * + * `nghttp3_conn_get_frame_payload_left2` returns the number of bytes + * left to read current frame payload for a stream denoted by + * |stream_id|. If no such stream is found, or |stream_id| identifies + * neither client bidirectional stream nor remote control stream, it + * returns 0. + * + * .. version-added:: 1.16.0 + */ +NGHTTP3_EXTERN uint64_t nghttp3_conn_get_frame_payload_left2( + const nghttp3_conn *conn, int64_t stream_id); + /** * @macrosection * @@ -3132,6 +3300,11 @@ typedef struct NGHTTP3_ALIGN(8) nghttp3_pri { /** * @function * + * .. warning:: + * + * .. version-deprecated:: 1.16.0 + * Use `nghttp3_conn_get_stream_priority2` instead. + * * `nghttp3_conn_get_stream_priority` stores stream priority of a * stream denoted by |stream_id| into |*dest|. |stream_id| must * identify client initiated bidirectional stream. Only server can @@ -3151,6 +3324,32 @@ typedef struct NGHTTP3_ALIGN(8) nghttp3_pri { NGHTTP3_EXTERN int nghttp3_conn_get_stream_priority_versioned( nghttp3_conn *conn, int pri_version, nghttp3_pri *dest, int64_t stream_id); +/** + * @function + * + * `nghttp3_conn_get_stream_priority2` stores stream priority of a + * stream denoted by |stream_id| into |*dest|. |stream_id| must + * identify client initiated bidirectional stream. Only server can + * use this function. + * + * This function must not be called if |conn| is initialized as + * client. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT` + * |stream_id| is not a client initiated bidirectional stream ID. + * :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND` + * Stream not found. + * + * .. version-added:: 1.16.0 + */ +NGHTTP3_EXTERN int +nghttp3_conn_get_stream_priority2_versioned(const nghttp3_conn *conn, + int pri_version, nghttp3_pri *dest, + int64_t stream_id); + /** * @function * @@ -3237,6 +3436,11 @@ NGHTTP3_EXTERN int nghttp3_check_header_value(const uint8_t *value, size_t len); /** * @function * + * .. warning:: + * + * .. version-deprecated:: 1.16.0 + * Use `nghttp3_conn_is_drained2` instead. + * * `nghttp3_conn_is_drained` returns nonzero if * `nghttp3_conn_shutdown` has been called, and there is no active * remote streams. This function is for server use only. @@ -3250,7 +3454,7 @@ NGHTTP3_EXTERN int nghttp3_conn_is_drained(nghttp3_conn *conn); * `nghttp3_conn_shutdown` has been called, and there is no active * remote streams. This function is for server use only. * - * This function has been available since v1.16.0. + * .. version-added:: 1.16.0 */ NGHTTP3_EXTERN int nghttp3_conn_is_drained2(const nghttp3_conn *conn); @@ -3498,31 +3702,39 @@ NGHTTP3_EXTERN const nghttp3_info *nghttp3_version(int least_version); NGHTTP3_EXTERN int nghttp3_err_is_fatal(int liberr); /* - * `nghttp3_get_varint` reads variable-length unsigned integer from + * `nghttp3_get_uvarint` reads variable-length unsigned integer from * |p|, and stores it in the buffer pointed by |dest| in host byte * order. It returns |p| plus the number of bytes read from |p|. */ -NGHTTP3_EXTERN const uint8_t *nghttp3_get_varint(int64_t *dest, - const uint8_t *p); +NGHTTP3_EXTERN const uint8_t *nghttp3_get_uvarint(uint64_t *dest, + const uint8_t *p); /* - * `nghttp3_get_varintlen` returns the required number of bytes to + * `nghttp3_get_uvarintlen` returns the required number of bytes to * read variable-length integer starting at |p|. */ -NGHTTP3_EXTERN size_t nghttp3_get_varintlen(const uint8_t *p); +NGHTTP3_EXTERN size_t nghttp3_get_uvarintlen(const uint8_t *p); /* - * `nghttp3_put_varint` writes |n| in |p| using variable-length + * `nghttp3_get_varint` reads variable-length unsigned integer from + * |p|, and stores it in the buffer pointed by |dest| in host byte + * order. It returns |p| plus the number of bytes read from |p|. + */ +NGHTTP3_EXTERN const uint8_t *nghttp3_get_varint(int64_t *dest, + const uint8_t *p); + +/* + * `nghttp3_put_uvarint` writes |n| in |p| using variable-length * integer encoding. It returns the one beyond of the last written * position. */ -NGHTTP3_EXTERN uint8_t *nghttp3_put_varint(uint8_t *p, int64_t n); +NGHTTP3_EXTERN uint8_t *nghttp3_put_uvarint(uint8_t *p, uint64_t n); /* - * `nghttp3_put_varintlen` returns the required number of bytes to + * `nghttp3_put_uvarintlen` returns the required number of bytes to * encode |n|. */ -NGHTTP3_EXTERN size_t nghttp3_put_varintlen(int64_t n); +NGHTTP3_EXTERN size_t nghttp3_put_uvarintlen(uint64_t n); /* * Versioned function wrappers @@ -3574,6 +3786,15 @@ NGHTTP3_EXTERN size_t nghttp3_put_varintlen(int64_t n); nghttp3_conn_get_stream_priority_versioned((CONN), NGHTTP3_PRI_VERSION, \ (DEST), (STREAM_ID)) +/* + * `nghttp3_conn_get_stream_priority2` is a wrapper around + * `nghttp3_conn_get_stream_priority2_versioned` to set the correct + * struct version. + */ +#define nghttp3_conn_get_stream_priority2(CONN, DEST, STREAM_ID) \ + nghttp3_conn_get_stream_priority2_versioned((CONN), NGHTTP3_PRI_VERSION, \ + (DEST), (STREAM_ID)) + /* * `nghttp3_pri_parse_priority` is a wrapper around * `nghttp3_pri_parse_priority_versioned` to set the correct struct diff --git a/deps/ngtcp2/nghttp3/lib/includes/nghttp3/version.h b/deps/ngtcp2/nghttp3/lib/includes/nghttp3/version.h index 3d38568d9f6519..f846051ac9966f 100644 --- a/deps/ngtcp2/nghttp3/lib/includes/nghttp3/version.h +++ b/deps/ngtcp2/nghttp3/lib/includes/nghttp3/version.h @@ -31,7 +31,7 @@ * * Version number of the nghttp3 library release. */ -#define NGHTTP3_VERSION "1.15.0" +#define NGHTTP3_VERSION "1.17.0-DEV" /** * @macro @@ -41,6 +41,6 @@ * number, 8 bits for minor and 8 bits for patch. Version 1.2.3 * becomes 0x010203. */ -#define NGHTTP3_VERSION_NUM 0x010f00 +#define NGHTTP3_VERSION_NUM 0x011100 #endif /* !defined(NGHTTP3_VERSION_H) */ diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_balloc.c b/deps/ngtcp2/nghttp3/lib/nghttp3_balloc.c index 25c0fef2f7b187..436310633349a6 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_balloc.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_balloc.c @@ -31,7 +31,7 @@ void nghttp3_balloc_init(nghttp3_balloc *balloc, size_t blklen, const nghttp3_mem *mem) { - assert((blklen & 0xfu) == 0); + assert((blklen & 0xFU) == 0); balloc->mem = mem; balloc->blklen = blklen; @@ -67,7 +67,7 @@ int nghttp3_balloc_get(nghttp3_balloc *balloc, void **pbuf, size_t n) { if (nghttp3_buf_left(&balloc->buf) < n) { p = nghttp3_mem_malloc(balloc->mem, - sizeof(nghttp3_memblock_hd) + 0x8u + balloc->blklen); + sizeof(nghttp3_memblock_hd) + 0x8U + balloc->blklen); if (p == NULL) { return NGHTTP3_ERR_NOMEM; } @@ -77,15 +77,15 @@ int nghttp3_balloc_get(nghttp3_balloc *balloc, void **pbuf, size_t n) { balloc->head = hd; nghttp3_buf_wrap_init( &balloc->buf, - (uint8_t *)(((uintptr_t)p + sizeof(nghttp3_memblock_hd) + 0xfu) & - ~(uintptr_t)0xfu), + (uint8_t *)(((uintptr_t)p + sizeof(nghttp3_memblock_hd) + 0xFU) & + ~(uintptr_t)0xFU), balloc->blklen); } - assert(((uintptr_t)balloc->buf.last & 0xfu) == 0); + assert(((uintptr_t)balloc->buf.last & 0xFU) == 0); *pbuf = balloc->buf.last; - balloc->buf.last += (n + 0xfu) & ~(uintptr_t)0xfu; + balloc->buf.last += (n + 0xFU) & ~(size_t)0xFU; return 0; } diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_callbacks.c b/deps/ngtcp2/nghttp3/lib/nghttp3_callbacks.c index 4e5111c4ca943a..283f479b0d3473 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_callbacks.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_callbacks.c @@ -45,7 +45,7 @@ nghttp3_callbacks_convert_to_latest(nghttp3_callbacks *dest, return src; } - memset(dest, 0, sizeof(*dest)); + *dest = (nghttp3_callbacks){0}; callbacks_copy(dest, src, callbacks_version); diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c b/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c index 10309589961662..30fe2f60fc514f 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_conn.c @@ -40,11 +40,23 @@ nghttp3_objalloc_def(chunk, nghttp3_chunk, oplent) +/* + * conn_remote_stream returns nonzero if |stream_id| is a remote + * stream ID. + */ +static int conn_remote_stream(const nghttp3_conn *conn, int64_t stream_id) { + if (conn->server) { + return !(stream_id & 0x1); + } + + return stream_id & 0x1; +} + /* * conn_remote_stream_uni returns nonzero if |stream_id| is remote * unidirectional stream ID. */ -static int conn_remote_stream_uni(nghttp3_conn *conn, int64_t stream_id) { +static int conn_remote_stream_uni(const nghttp3_conn *conn, int64_t stream_id) { if (conn->server) { return (stream_id & 0x03) == 0x02; } @@ -317,6 +329,29 @@ static int conn_call_recv_wt_data(nghttp3_conn *conn, return 0; } +static int conn_call_wt_data_stream_open(nghttp3_conn *conn, + const nghttp3_stream *stream) { + nghttp3_wt_session *wt_session; + int rv; + + if (!conn->callbacks.wt_data_stream_open) { + return 0; + } + + wt_session = stream->wt.session; + + assert(wt_session); + + rv = conn->callbacks.wt_data_stream_open(conn, wt_session->session_id, + stream->node.id, conn->user_data, + stream->user_data); + if (rv != 0) { + return NGHTTP3_ERR_CALLBACK_FAILURE; + } + + return 0; +} + static int conn_glitch_ratelim_drain(nghttp3_conn *conn, uint64_t n, nghttp3_tstamp ts) { if (ts == UINT64_MAX) { @@ -575,7 +610,7 @@ nghttp3_ssize nghttp3_conn_read_stream2(nghttp3_conn *conn, int64_t stream_id, } conn->rx.max_stream_id_bidi = - nghttp3_max_int64(conn->rx.max_stream_id_bidi, stream_id); + nghttp3_max(conn->rx.max_stream_id_bidi, stream_id); rv = nghttp3_conn_create_stream(conn, &stream, stream_id); if (rv != 0) { return rv; @@ -664,7 +699,7 @@ static nghttp3_ssize conn_read_type(nghttp3_conn *conn, nghttp3_stream *stream, nghttp3_stream_read_state *rstate = &stream->rstate; nghttp3_varint_read_state *rvint = &rstate->rvint; nghttp3_ssize nread; - int64_t stream_type; + uint64_t stream_type; assert(srclen); @@ -747,10 +782,7 @@ nghttp3_ssize nghttp3_conn_read_uni(nghttp3_conn *conn, nghttp3_stream *stream, return NGHTTP3_ERR_H3_EXCESSIVE_LOAD; } - rv = conn_delete_stream(conn, stream); - assert(0 == rv); - - return 0; + return conn_delete_stream(conn, stream); } nread = conn_read_type(conn, stream, src, srclen, fin); if (nread < 0) { @@ -826,8 +858,8 @@ static void conn_reset_rx_originlen(nghttp3_conn *conn) { conn->rx.originlen = 0; } -static int frame_fin(nghttp3_stream_read_state *rstate, size_t len) { - return (int64_t)len >= rstate->left; +static int frame_fin(const nghttp3_stream_read_state *rstate, size_t len) { + return len >= rstate->left; } nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, @@ -1011,7 +1043,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, } /* Read Identifier */ - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); assert(len > 0); nread = nghttp3_read_varint(rvint, p, p + len, frame_fin(rstate, len)); if (nread < 0) { @@ -1020,12 +1052,12 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, p += nread; nconsumed += (size_t)nread; - rstate->left -= nread; + rstate->left -= (uint64_t)nread; if (rvint->left) { rstate->state = NGHTTP3_CTRL_STREAM_STATE_SETTINGS_ID; return (nghttp3_ssize)nconsumed; } - rstate->fr.settings.iv[0].id = (uint64_t)rvint->acc; + rstate->fr.settings.iv[0].id = rvint->acc; nghttp3_varint_read_state_reset(rvint); /* Read Value */ @@ -1046,12 +1078,12 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, p += nread; nconsumed += (size_t)nread; - rstate->left -= nread; + rstate->left -= (uint64_t)nread; if (rvint->left) { rstate->state = NGHTTP3_CTRL_STREAM_STATE_SETTINGS_VALUE; return (nghttp3_ssize)nconsumed; } - rstate->fr.settings.iv[0].value = (uint64_t)rvint->acc; + rstate->fr.settings.iv[0].value = rvint->acc; nghttp3_varint_read_state_reset(rvint); rv = @@ -1062,7 +1094,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, } break; case NGHTTP3_CTRL_STREAM_STATE_SETTINGS_ID: - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); assert(len > 0); nread = nghttp3_read_varint(rvint, p, p + len, frame_fin(rstate, len)); if (nread < 0) { @@ -1071,11 +1103,11 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, p += nread; nconsumed += (size_t)nread; - rstate->left -= nread; + rstate->left -= (uint64_t)nread; if (rvint->left) { return (nghttp3_ssize)nconsumed; } - rstate->fr.settings.iv[0].id = (uint64_t)rvint->acc; + rstate->fr.settings.iv[0].id = rvint->acc; nghttp3_varint_read_state_reset(rvint); if (rstate->left == 0) { @@ -1089,7 +1121,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, } /* Fall through */ case NGHTTP3_CTRL_STREAM_STATE_SETTINGS_VALUE: - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); assert(len > 0); nread = nghttp3_read_varint(rvint, p, p + len, frame_fin(rstate, len)); if (nread < 0) { @@ -1098,11 +1130,11 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, p += nread; nconsumed += (size_t)nread; - rstate->left -= nread; + rstate->left -= (uint64_t)nread; if (rvint->left) { return (nghttp3_ssize)nconsumed; } - rstate->fr.settings.iv[0].value = (uint64_t)rvint->acc; + rstate->fr.settings.iv[0].value = rvint->acc; nghttp3_varint_read_state_reset(rvint); rv = nghttp3_conn_on_settings_entry_received(conn, &rstate->fr.settings); @@ -1123,7 +1155,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, nghttp3_stream_read_state_reset(rstate); break; case NGHTTP3_CTRL_STREAM_STATE_GOAWAY: - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); assert(len > 0); nread = nghttp3_read_varint(rvint, p, p + len, frame_fin(rstate, len)); if (nread < 0) { @@ -1132,26 +1164,26 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, p += nread; nconsumed += (size_t)nread; - rstate->left -= nread; + rstate->left -= (uint64_t)nread; if (rvint->left) { return (nghttp3_ssize)nconsumed; } - if (!conn->server && !nghttp3_client_stream_bidi(rvint->acc)) { + if (!conn->server && !nghttp3_client_stream_bidi((int64_t)rvint->acc)) { return NGHTTP3_ERR_H3_ID_ERROR; } - if (conn->rx.goaway_id < rvint->acc) { + if (conn->rx.goaway_id < (int64_t)rvint->acc) { return NGHTTP3_ERR_H3_ID_ERROR; } /* Receiving same GOAWAY ID is suspicious. */ - if (conn->rx.goaway_id == rvint->acc && + if (conn->rx.goaway_id == (int64_t)rvint->acc && conn_glitch_ratelim_drain(conn, 1, ts) != 0) { return NGHTTP3_ERR_H3_EXCESSIVE_LOAD; } conn->flags |= NGHTTP3_CONN_FLAG_GOAWAY_RECVED; - conn->rx.goaway_id = rvint->acc; + conn->rx.goaway_id = (int64_t)rvint->acc; nghttp3_varint_read_state_reset(rvint); if (conn->callbacks.shutdown) { @@ -1166,7 +1198,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, break; case NGHTTP3_CTRL_STREAM_STATE_MAX_PUSH_ID: /* server side only */ - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); assert(len > 0); nread = nghttp3_read_varint(rvint, p, p + len, frame_fin(rstate, len)); if (nread < 0) { @@ -1175,29 +1207,29 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, p += nread; nconsumed += (size_t)nread; - rstate->left -= nread; + rstate->left -= (uint64_t)nread; if (rvint->left) { return (nghttp3_ssize)nconsumed; } - if (conn->local.uni.max_pushes > (uint64_t)rvint->acc + 1) { + if (conn->local.uni.max_pushes > rvint->acc + 1) { return NGHTTP3_ERR_H3_FRAME_ERROR; } /* Receiving same MAX_PUSH_ID is suspicious. */ - if (conn->local.uni.max_pushes == (uint64_t)rvint->acc + 1 && + if (conn->local.uni.max_pushes == rvint->acc + 1 && conn_glitch_ratelim_drain(conn, 1, ts) != 0) { return NGHTTP3_ERR_H3_EXCESSIVE_LOAD; } - conn->local.uni.max_pushes = (uint64_t)rvint->acc + 1; + conn->local.uni.max_pushes = rvint->acc + 1; nghttp3_varint_read_state_reset(rvint); nghttp3_stream_read_state_reset(rstate); break; case NGHTTP3_CTRL_STREAM_STATE_PRIORITY_UPDATE_PRI_ELEM_ID: /* server side only */ - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); assert(len > 0); nread = nghttp3_read_varint(rvint, p, p + len, frame_fin(rstate, len)); if (nread < 0) { @@ -1206,12 +1238,12 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, p += nread; nconsumed += (size_t)nread; - rstate->left -= nread; + rstate->left -= (uint64_t)nread; if (rvint->left) { return (nghttp3_ssize)nconsumed; } - rstate->fr.priority_update.pri_elem_id = rvint->acc; + rstate->fr.priority_update.pri_elem_id = (int64_t)rvint->acc; nghttp3_varint_read_state_reset(rvint); if (rstate->left == 0) { @@ -1240,9 +1272,9 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, case NGHTTP3_CTRL_STREAM_STATE_PRIORITY_UPDATE: /* We need to buffer Priority Field Value because it might be fragmented. */ - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); assert(len > 0); - if (conn->rx.pri_fieldbuflen == 0 && rstate->left == (int64_t)len) { + if (conn->rx.pri_fieldbuflen == 0 && rstate->left == len) { /* Everything is in the input buffer. Apply same length limit we impose when buffering the field. */ if (len > sizeof(conn->rx.pri_fieldbuf)) { @@ -1262,7 +1294,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, memcpy(conn->rx.pri_fieldbuf + conn->rx.pri_fieldbuflen, p, len); conn->rx.pri_fieldbuflen += len; - if (rstate->left == (int64_t)len) { + if (rstate->left == len) { pri_field_value = conn->rx.pri_fieldbuf; pri_field_valuelen = conn->rx.pri_fieldbuflen; } @@ -1270,7 +1302,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, p += len; nconsumed += len; - rstate->left -= (int64_t)len; + rstate->left -= len; if (rstate->left) { return (nghttp3_ssize)nconsumed; @@ -1295,7 +1327,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, break; case NGHTTP3_CTRL_STREAM_STATE_ORIGIN_ORIGIN_LEN: /* client side only */ - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); assert(len > 0); @@ -1310,7 +1342,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, } nconsumed += (size_t)nread; - rstate->left -= nread; + rstate->left -= (uint64_t)nread; len -= (size_t)nread; if (conn->rx.originlen_offset < sizeof(conn->rx.originlen)) { @@ -1342,7 +1374,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, /* No need to update p because we will return very soon. */ nconsumed += len; - rstate->left -= (int64_t)len; + rstate->left -= len; conn->rx.originbuflen = len; @@ -1383,8 +1415,8 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, break; case NGHTTP3_CTRL_STREAM_STATE_ORIGIN_ASCII_ORIGIN: /* client side only */ - len = nghttp3_min_size(conn->rx.originlen - conn->rx.originbuflen, - (size_t)(end - p)); + len = nghttp3_min(conn->rx.originlen - conn->rx.originbuflen, + (size_t)(end - p)); assert(len > 0); @@ -1393,7 +1425,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, conn->rx.originbuflen += len; p += len; nconsumed += len; - rstate->left -= (int64_t)len; + rstate->left -= len; if (conn->rx.originbuflen < conn->rx.originlen) { return (nghttp3_ssize)nconsumed; @@ -1421,10 +1453,10 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, break; case NGHTTP3_CTRL_STREAM_STATE_IGN_FRAME: - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); p += len; nconsumed += len; - rstate->left -= (int64_t)len; + rstate->left -= len; if (rstate->left) { return (nghttp3_ssize)nconsumed; @@ -1470,7 +1502,6 @@ static int conn_unlink_wt_session(nghttp3_conn *conn, } static int conn_delete_stream(nghttp3_conn *conn, nghttp3_stream *stream) { - int bidi = nghttp3_client_stream_bidi(stream->node.id); int rv; rv = conn_call_deferred_consume(conn, stream, @@ -1479,23 +1510,20 @@ static int conn_delete_stream(nghttp3_conn *conn, nghttp3_stream *stream) { return rv; } - if (bidi) { - if (stream->qpack_blocked_pe.index != NGHTTP3_PQ_BAD_INDEX) { - nghttp3_conn_qpack_blocked_streams_remove(conn, stream); + if (stream->qpack_blocked_pe.index != NGHTTP3_PQ_BAD_INDEX) { + nghttp3_conn_qpack_blocked_streams_remove(conn, stream); - rv = nghttp3_qpack_decoder_cancel_stream(&conn->qdec, stream->node.id); - if (rv != 0) { - return rv; - } + rv = nghttp3_qpack_decoder_cancel_stream(&conn->qdec, stream->node.id); + if (rv != 0) { + return rv; } + } - if (conn->callbacks.stream_close) { - rv = - conn->callbacks.stream_close(conn, stream->node.id, stream->error_code, - conn->user_data, stream->user_data); - if (rv != 0) { - return NGHTTP3_ERR_CALLBACK_FAILURE; - } + if (conn->callbacks.stream_close) { + rv = conn->callbacks.stream_close(conn, stream->node.id, stream->error_code, + conn->user_data, stream->user_data); + if (rv != 0) { + return NGHTTP3_ERR_CALLBACK_FAILURE; } } @@ -1585,7 +1613,7 @@ nghttp3_ssize nghttp3_conn_read_qpack_encoder(nghttp3_conn *conn, for (; !nghttp3_pq_empty(&conn->qpack_blocked_streams);) { stream = nghttp3_struct_of(nghttp3_pq_top(&conn->qpack_blocked_streams), nghttp3_stream, qpack_blocked_pe); - if (nghttp3_qpack_stream_context_get_ricnt(&stream->qpack_sctx) > + if (nghttp3_qpack_stream_context_get_ricnt2(&stream->qpack_sctx) > nghttp3_qpack_decoder_get_icnt(&conn->qdec)) { break; } @@ -1781,7 +1809,7 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, } /* rstate->left is Session ID */ - rv = nghttp3_conn_on_wt_stream(conn, stream, rstate->left); + rv = nghttp3_conn_on_wt_stream(conn, stream, (int64_t)rstate->left); if (rv != 0) { if (rv != NGHTTP3_ERR_WT_SESSION_GONE) { return rv; @@ -1827,7 +1855,7 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, } break; case NGHTTP3_REQ_STREAM_STATE_DATA: - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); nread = nghttp3_conn_on_data(conn, stream, p, len); if (nread < 0) { if (nread != NGHTTP3_ERR_WT_SESSION_GONE) { @@ -1851,7 +1879,7 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, } p += len; nconsumed += (size_t)nread; - rstate->left -= (int64_t)len; + rstate->left -= len; if (rstate->left) { goto almost_done; @@ -1864,16 +1892,16 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, nghttp3_stream_read_state_reset(rstate); break; case NGHTTP3_REQ_STREAM_STATE_HEADERS: - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); - nread = nghttp3_conn_on_headers(conn, stream, p, len, - (int64_t)len == rstate->left); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); + nread = + nghttp3_conn_on_headers(conn, stream, p, len, len == rstate->left); if (nread < 0) { return nread; } p += nread; nconsumed += (size_t)nread; - rstate->left -= nread; + rstate->left -= (uint64_t)nread; if (stream->flags & NGHTTP3_STREAM_FLAG_QPACK_DECODE_BLOCKED) { if (p != end && nghttp3_stream_get_buffered_datalen(stream) == 0) { @@ -2004,10 +2032,10 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc, break; case NGHTTP3_REQ_STREAM_STATE_IGN_FRAME: - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); p += len; nconsumed += len; - rstate->left -= (int64_t)len; + rstate->left -= len; if (rstate->left) { goto almost_done; @@ -2275,7 +2303,7 @@ int nghttp3_conn_on_settings_entry_received(nghttp3_conn *conn, dest->qpack_blocked_streams = (size_t)ent->value; nghttp3_qpack_encoder_set_max_blocked_streams( - &conn->qenc, (size_t)nghttp3_min_uint64(100, ent->value)); + &conn->qenc, (size_t)nghttp3_min(100, ent->value)); break; case NGHTTP3_SETTINGS_ID_ENABLE_CONNECT_PROTOCOL: if (conn->server) { @@ -2393,7 +2421,7 @@ conn_on_priority_update_stream(nghttp3_conn *conn, } conn->rx.max_stream_id_bidi = - nghttp3_max_int64(conn->rx.max_stream_id_bidi, stream_id); + nghttp3_max(conn->rx.max_stream_id_bidi, stream_id); rv = nghttp3_conn_create_stream(conn, &stream, stream_id); if (rv != 0) { return rv; @@ -2450,11 +2478,11 @@ int nghttp3_conn_create_stream(nghttp3_conn *conn, nghttp3_stream **pstream, int64_t stream_id) { nghttp3_stream *stream; int rv; + static const nghttp3_stream_callbacks callbacks = { + .acked_data = conn_stream_acked_data, + }; - rv = nghttp3_stream_new(&stream, stream_id, - &(nghttp3_stream_callbacks){ - .acked_data = conn_stream_acked_data, - }, + rv = nghttp3_stream_new(&stream, stream_id, &callbacks, &conn->out_chunk_objalloc, &conn->stream_objalloc, conn->mem); if (rv != 0) { @@ -2479,14 +2507,14 @@ int nghttp3_conn_create_stream(nghttp3_conn *conn, nghttp3_stream **pstream, return 0; } -nghttp3_stream *nghttp3_conn_find_stream(nghttp3_conn *conn, +nghttp3_stream *nghttp3_conn_find_stream(const nghttp3_conn *conn, int64_t stream_id) { return nghttp3_map_find(&conn->streams, (nghttp3_map_key_type)stream_id); } int nghttp3_conn_bind_control_stream(nghttp3_conn *conn, int64_t stream_id) { nghttp3_stream *stream; - nghttp3_frame fr; + nghttp3_frame *fr; int rv; assert(stream_id >= 0); @@ -2512,28 +2540,28 @@ int nghttp3_conn_bind_control_stream(nghttp3_conn *conn, int64_t stream_id) { return rv; } - fr.settings = (nghttp3_frame_settings){ - .type = NGHTTP3_FRAME_SETTINGS, - .local_settings = &conn->local.settings, - }; - - rv = nghttp3_stream_frq_add(stream, &fr); + rv = nghttp3_stream_frq_emplace(stream, &fr); if (rv != 0) { return rv; } + fr->settings = (nghttp3_frame_settings){ + .type = NGHTTP3_FRAME_SETTINGS, + .local_settings = &conn->local.settings, + }; + if (conn->local.settings.origin_list) { assert(conn->server); - fr.origin = (nghttp3_frame_origin){ - .type = NGHTTP3_FRAME_ORIGIN, - .origin_list = *conn->local.settings.origin_list, - }; - - rv = nghttp3_stream_frq_add(stream, &fr); + rv = nghttp3_stream_frq_emplace(stream, &fr); if (rv != 0) { return rv; } + + fr->origin = (nghttp3_frame_origin){ + .type = NGHTTP3_FRAME_ORIGIN, + .origin_list = *conn->local.settings.origin_list, + }; } return 0; @@ -2776,38 +2804,36 @@ static int conn_submit_headers_data(nghttp3_conn *conn, nghttp3_stream *stream, const nghttp3_data_reader *dr) { int rv; nghttp3_nv *nnva; - nghttp3_frame fr; + nghttp3_frame *fr; rv = nghttp3_nva_copy(&nnva, nva, nvlen, conn->mem); if (rv != 0) { return rv; } - fr.headers = (nghttp3_frame_headers){ - .type = NGHTTP3_FRAME_HEADERS, - .nva = nnva, - .nvlen = nvlen, - }; - - rv = nghttp3_stream_frq_add(stream, &fr); + rv = nghttp3_stream_frq_emplace(stream, &fr); if (rv != 0) { nghttp3_nva_del(nnva, conn->mem); return rv; } - if (dr && dr->read_data != wt_session_read_data) { - fr.data = (nghttp3_frame_data){ - .type = NGHTTP3_FRAME_DATA, - .dr = *dr, - }; + fr->headers = (nghttp3_frame_headers){ + .type = NGHTTP3_FRAME_HEADERS, + .nva = nnva, + .nvlen = nvlen, + }; - rv = nghttp3_stream_frq_add(stream, &fr); + if (dr && dr->read_data != wt_session_read_data) { + rv = nghttp3_stream_frq_emplace(stream, &fr); if (rv != 0) { return rv; } - } - + fr->data = (nghttp3_frame_data){ + .type = NGHTTP3_FRAME_DATA, + .dr = *dr, + }; + } if (nghttp3_stream_require_schedule(stream)) { return nghttp3_conn_schedule_stream(conn, stream); @@ -2951,51 +2977,51 @@ int nghttp3_conn_submit_trailers(nghttp3_conn *conn, int64_t stream_id, } int nghttp3_conn_submit_shutdown_notice(nghttp3_conn *conn) { - nghttp3_frame fr; + nghttp3_frame *fr; int rv; assert(conn->tx.ctrl); - fr.goaway = (nghttp3_frame_goaway){ + rv = nghttp3_stream_frq_emplace(conn->tx.ctrl, &fr); + if (rv != 0) { + return rv; + } + + fr->goaway = (nghttp3_frame_goaway){ .type = NGHTTP3_FRAME_GOAWAY, .id = conn->server ? NGHTTP3_SHUTDOWN_NOTICE_STREAM_ID : NGHTTP3_SHUTDOWN_NOTICE_PUSH_ID, }; - assert(fr.goaway.id <= conn->tx.goaway_id); + assert(fr->goaway.id <= conn->tx.goaway_id); - rv = nghttp3_stream_frq_add(conn->tx.ctrl, &fr); - if (rv != 0) { - return rv; - } - - conn->tx.goaway_id = fr.goaway.id; + conn->tx.goaway_id = fr->goaway.id; conn->flags |= NGHTTP3_CONN_FLAG_GOAWAY_QUEUED; return 0; } int nghttp3_conn_shutdown(nghttp3_conn *conn) { - nghttp3_frame fr; + nghttp3_frame *fr; int rv; assert(conn->tx.ctrl); - fr.goaway = (nghttp3_frame_goaway){ - .type = NGHTTP3_FRAME_GOAWAY, - .id = conn->server ? nghttp3_min_int64((1ll << 62) - 4, - conn->rx.max_stream_id_bidi + 4) - : 0, - }; - - assert(fr.goaway.id <= conn->tx.goaway_id); - - rv = nghttp3_stream_frq_add(conn->tx.ctrl, &fr); + rv = nghttp3_stream_frq_emplace(conn->tx.ctrl, &fr); if (rv != 0) { return rv; } - conn->tx.goaway_id = fr.goaway.id; + fr->goaway = (nghttp3_frame_goaway){ + .type = NGHTTP3_FRAME_GOAWAY, + .id = conn->server + ? nghttp3_min((1LL << 62) - 4, conn->rx.max_stream_id_bidi + 4) + : 0, + }; + + assert(fr->goaway.id <= conn->tx.goaway_id); + + conn->tx.goaway_id = fr->goaway.id; conn->flags |= NGHTTP3_CONN_FLAG_GOAWAY_QUEUED | NGHTTP3_CONN_FLAG_SHUTDOWN_COMMENCED; @@ -3074,7 +3100,12 @@ int nghttp3_conn_unblock_stream(nghttp3_conn *conn, int64_t stream_id) { } int nghttp3_conn_is_stream_writable(nghttp3_conn *conn, int64_t stream_id) { - nghttp3_stream *stream = nghttp3_conn_find_stream(conn, stream_id); + return nghttp3_conn_is_stream_writable2(conn, stream_id); +} + +int nghttp3_conn_is_stream_writable2(const nghttp3_conn *conn, + int64_t stream_id) { + const nghttp3_stream *stream = nghttp3_conn_find_stream(conn, stream_id); if (stream == NULL) { return 0; @@ -3198,9 +3229,29 @@ int nghttp3_conn_set_stream_user_data(nghttp3_conn *conn, int64_t stream_id, return 0; } +void *nghttp3_conn_get_stream_user_data(const nghttp3_conn *conn, + int64_t stream_id) { + nghttp3_stream *stream; + + assert(stream_id >= 0); + assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT); + + stream = nghttp3_conn_find_stream(conn, stream_id); + if (stream == NULL) { + return NULL; + } + + return stream->user_data; +} + uint64_t nghttp3_conn_get_frame_payload_left(nghttp3_conn *conn, int64_t stream_id) { - nghttp3_stream *stream; + return nghttp3_conn_get_frame_payload_left2(conn, stream_id); +} + +uint64_t nghttp3_conn_get_frame_payload_left2(const nghttp3_conn *conn, + int64_t stream_id) { + const nghttp3_stream *stream; int uni = 0; assert(stream_id >= 0); @@ -3222,14 +3273,22 @@ uint64_t nghttp3_conn_get_frame_payload_left(nghttp3_conn *conn, return 0; } - return (uint64_t)stream->rstate.left; + return stream->rstate.left; } int nghttp3_conn_get_stream_priority_versioned(nghttp3_conn *conn, int pri_version, nghttp3_pri *dest, int64_t stream_id) { - nghttp3_stream *stream; + return nghttp3_conn_get_stream_priority2_versioned(conn, pri_version, dest, + stream_id); +} + +int nghttp3_conn_get_stream_priority2_versioned(const nghttp3_conn *conn, + int pri_version, + nghttp3_pri *dest, + int64_t stream_id) { + const nghttp3_stream *stream; (void)pri_version; assert(conn->server); @@ -3255,7 +3314,8 @@ int nghttp3_conn_set_client_stream_priority(nghttp3_conn *conn, const uint8_t *data, size_t datalen) { nghttp3_stream *stream; - nghttp3_frame fr; + nghttp3_frame *fr; + int rv; uint8_t *buf = NULL; assert(!conn->server); @@ -3280,14 +3340,20 @@ int nghttp3_conn_set_client_stream_priority(nghttp3_conn *conn, memcpy(buf, data, datalen); } - fr.priority_update = (nghttp3_frame_priority_update){ + rv = nghttp3_stream_frq_emplace(conn->tx.ctrl, &fr); + if (rv != 0) { + nghttp3_mem_free(conn->mem, buf); + return rv; + } + + fr->priority_update = (nghttp3_frame_priority_update){ .type = NGHTTP3_FRAME_PRIORITY_UPDATE, .pri_elem_id = stream_id, .data = buf, .datalen = datalen, }; - return nghttp3_stream_frq_add(conn->tx.ctrl, &fr); + return 0; } int nghttp3_conn_set_server_stream_priority_versioned(nghttp3_conn *conn, @@ -3318,6 +3384,10 @@ int nghttp3_conn_set_server_stream_priority_versioned(nghttp3_conn *conn, } int nghttp3_conn_is_drained(nghttp3_conn *conn) { + return nghttp3_conn_is_drained2(conn); +} + +int nghttp3_conn_is_drained2(const nghttp3_conn *conn) { assert(conn->server); return (conn->flags & NGHTTP3_CONN_FLAG_SHUTDOWN_COMMENCED) && @@ -3417,8 +3487,8 @@ int nghttp3_conn_open_wt_data_stream(nghttp3_conn *conn, int64_t session_id, void *stream_user_data) { nghttp3_stream *stream, *wt_ctrl_stream; nghttp3_wt_session *wt_session; - nghttp3_frame fr; - int64_t type; + nghttp3_frame *fr; + uint64_t type; int rv; int remote_bidi = 0; @@ -3525,7 +3595,12 @@ int nghttp3_conn_open_wt_data_stream(nghttp3_conn *conn, int64_t session_id, stream->rstate.state = NGHTTP3_REQ_STREAM_STATE_BEFORE_WT_DATA; } - fr.wt = (nghttp3_frame_ex_wt){ + rv = nghttp3_stream_frq_emplace(stream, &fr); + if (rv != 0) { + return rv; + } + + fr->wt = (nghttp3_frame_ex_wt){ .type = NGHTTP3_FRAME_EX_WT, .fr.wt_stream = { @@ -3535,13 +3610,6 @@ int nghttp3_conn_open_wt_data_stream(nghttp3_conn *conn, int64_t session_id, }, }; - rv = nghttp3_stream_frq_add(stream, &fr); - if (rv != 0) { - return rv; - } - - - if (nghttp3_stream_require_schedule(stream)) { return nghttp3_conn_ensure_stream_scheduled(conn, stream); } @@ -3586,6 +3654,11 @@ int nghttp3_conn_close_wt_session(nghttp3_conn *conn, int64_t session_id, wt_session->tx.error_msg.len = msglen; } + rv = nghttp3_stream_frq_emplace(stream, &fr); + if (rv != 0) { + return rv; + } + fr->cpsl = (nghttp3_frame_ex_cpsl){ .type = NGHTTP3_FRAME_EX_CPSL, .fr.wt_close_session = @@ -3596,12 +3669,6 @@ int nghttp3_conn_close_wt_session(nghttp3_conn *conn, int64_t session_id, }, }; - rv = nghttp3_stream_frq_add(stream, &fr); - if (rv != 0) { - return rv; - } - - if (nghttp3_stream_require_schedule(stream)) { rv = nghttp3_conn_schedule_stream(conn, stream); if (rv != 0) { @@ -3668,7 +3735,7 @@ int nghttp3_conn_on_wt_stream(nghttp3_conn *conn, nghttp3_stream *stream, } conn->rx.max_stream_id_bidi = - nghttp3_max_int64(conn->rx.max_stream_id_bidi, session_id); + nghttp3_max(conn->rx.max_stream_id_bidi, session_id); rv = nghttp3_conn_create_stream(conn, &wt_ctrl_stream, session_id); if (rv != 0) { return rv; @@ -3690,6 +3757,10 @@ int nghttp3_conn_on_wt_stream(nghttp3_conn *conn, nghttp3_stream *stream, nghttp3_wt_session_add_stream(wt_session, stream); + if (wt_ctrl_stream->wt.session->flags & NGHTTP3_WT_SESSION_FLAG_CONFIRMED) { + return conn_call_wt_data_stream_open(conn, stream); + } + return 0; } @@ -3706,6 +3777,13 @@ int nghttp3_conn_on_wt_session_confirmed(nghttp3_conn *conn, for (stream = wt_session->head; stream; stream = stream->wt.next) { stream->flags &= (uint16_t)~NGHTTP3_STREAM_FLAG_WT_SESSION_BLOCKED; + if (conn_remote_stream(conn, stream->node.id)) { + rv = conn_call_wt_data_stream_open(conn, stream); + if (rv != 0) { + return rv; + } + } + rv = nghttp3_conn_process_blocked_wt_stream_data(conn, stream, ts); if (rv != 0) { return rv; @@ -3769,7 +3847,7 @@ nghttp3_ssize nghttp3_conn_read_wt_stream_uni(nghttp3_conn *conn, nghttp3_varint_read_state_reset(rvint); /* rstate->left is Session ID */ - rv = nghttp3_conn_on_wt_stream(conn, stream, rstate->left); + rv = nghttp3_conn_on_wt_stream(conn, stream, (int64_t)rstate->left); if (rv != 0) { if (rv != NGHTTP3_ERR_WT_SESSION_GONE) { return rv; diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_conn.h b/deps/ngtcp2/nghttp3/lib/nghttp3_conn.h index 67367c397b83d5..68219682fb0485 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_conn.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_conn.h @@ -48,28 +48,28 @@ #define NGHTTP3_QPACK_ENCODER_MAX_BLOCK_STREAMS 100 /* NGHTTP3_CONN_FLAG_NONE indicates that no flag is set. */ -#define NGHTTP3_CONN_FLAG_NONE 0x0000u +#define NGHTTP3_CONN_FLAG_NONE 0x0000U /* NGHTTP3_CONN_FLAG_SETTINGS_RECVED is set when SETTINGS frame has been received. */ -#define NGHTTP3_CONN_FLAG_SETTINGS_RECVED 0x0001u +#define NGHTTP3_CONN_FLAG_SETTINGS_RECVED 0x0001U /* NGHTTP3_CONN_FLAG_CONTROL_OPENED is set when a control stream has opened. */ -#define NGHTTP3_CONN_FLAG_CONTROL_OPENED 0x0002u +#define NGHTTP3_CONN_FLAG_CONTROL_OPENED 0x0002U /* NGHTTP3_CONN_FLAG_QPACK_ENCODER_OPENED is set when a QPACK encoder stream has opened. */ -#define NGHTTP3_CONN_FLAG_QPACK_ENCODER_OPENED 0x0004u +#define NGHTTP3_CONN_FLAG_QPACK_ENCODER_OPENED 0x0004U /* NGHTTP3_CONN_FLAG_QPACK_DECODER_OPENED is set when a QPACK decoder stream has opened. */ -#define NGHTTP3_CONN_FLAG_QPACK_DECODER_OPENED 0x0008u +#define NGHTTP3_CONN_FLAG_QPACK_DECODER_OPENED 0x0008U /* NGHTTP3_CONN_FLAG_SHUTDOWN_COMMENCED is set when graceful shutdown has started. */ -#define NGHTTP3_CONN_FLAG_SHUTDOWN_COMMENCED 0x0010u +#define NGHTTP3_CONN_FLAG_SHUTDOWN_COMMENCED 0x0010U /* NGHTTP3_CONN_FLAG_GOAWAY_RECVED indicates that GOAWAY frame has received. */ -#define NGHTTP3_CONN_FLAG_GOAWAY_RECVED 0x0020u +#define NGHTTP3_CONN_FLAG_GOAWAY_RECVED 0x0020U /* NGHTTP3_CONN_FLAG_GOAWAY_QUEUED indicates that GOAWAY frame has been submitted for transmission. */ -#define NGHTTP3_CONN_FLAG_GOAWAY_QUEUED 0x0040u +#define NGHTTP3_CONN_FLAG_GOAWAY_QUEUED 0x0040U typedef struct nghttp3_chunk { nghttp3_opl_entry oplent; @@ -175,7 +175,8 @@ struct nghttp3_conn { } tx; }; -nghttp3_stream *nghttp3_conn_find_stream(nghttp3_conn *conn, int64_t stream_id); +nghttp3_stream *nghttp3_conn_find_stream(const nghttp3_conn *conn, + int64_t stream_id); int nghttp3_conn_create_stream(nghttp3_conn *conn, nghttp3_stream **pstream, int64_t stream_id); diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_conv.c b/deps/ngtcp2/nghttp3/lib/nghttp3_conv.c index bb2e65ce5cf2e7..a90e1d25b70eab 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_conv.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_conv.c @@ -31,7 +31,7 @@ #include "nghttp3_str.h" #include "nghttp3_unreachable.h" -const uint8_t *nghttp3_get_varint(int64_t *dest, const uint8_t *p) { +const uint8_t *nghttp3_get_uvarint(uint64_t *dest, const uint8_t *p) { uint16_t n16; uint32_t n32; uint64_t n64; @@ -43,22 +43,22 @@ const uint8_t *nghttp3_get_varint(int64_t *dest, const uint8_t *p) { case 1: memcpy(&n16, p, 2); n16 = ntohs(n16); - n16 &= 0x3fff; + n16 &= 0x3FFFU; *dest = n16; return p + 2; case 2: memcpy(&n32, p, 4); n32 = ntohl(n32); - n32 &= 0x3fffffff; + n32 &= 0x3FFFFFFFU; *dest = n32; return p + 4; case 3: memcpy(&n64, p, 8); n64 = nghttp3_ntohl64(n64); - n64 &= 0x3fffffffffffffff; - *dest = (int64_t)n64; + n64 &= 0x3FFFFFFFFFFFFFFFU; + *dest = n64; return p + 8; default: @@ -66,8 +66,17 @@ const uint8_t *nghttp3_get_varint(int64_t *dest, const uint8_t *p) { } } -size_t nghttp3_get_varintlen(const uint8_t *p) { - return (size_t)(1u << (*p >> 6)); +size_t nghttp3_get_uvarintlen(const uint8_t *p) { + return (size_t)(1U << (*p >> 6)); +} + +const uint8_t *nghttp3_get_varint(int64_t *dest, const uint8_t *p) { + uint64_t n; + + p = nghttp3_get_uvarint(&n, p); + *dest = (int64_t)n; + + return p; } const uint8_t *nghttp3_get_uint32be(uint32_t *dest, const uint8_t *p) { @@ -91,7 +100,7 @@ uint8_t *nghttp3_put_uint16be(uint8_t *p, uint16_t n) { return nghttp3_cpymem(p, (const uint8_t *)&n, sizeof(n)); } -uint8_t *nghttp3_put_varint(uint8_t *p, int64_t n) { +uint8_t *nghttp3_put_uvarint(uint8_t *p, uint64_t n) { uint8_t *rv; if (n < 64) { *p++ = (uint8_t)n; @@ -99,21 +108,21 @@ uint8_t *nghttp3_put_varint(uint8_t *p, int64_t n) { } if (n < 16384) { rv = nghttp3_put_uint16be(p, (uint16_t)n); - *p |= 0x40; + *p |= 0x40U; return rv; } if (n < 1073741824) { rv = nghttp3_put_uint32be(p, (uint32_t)n); - *p |= 0x80; + *p |= 0x80U; return rv; } - assert(n < 4611686018427387904LL); - rv = nghttp3_put_uint64be(p, (uint64_t)n); - *p |= 0xc0; + assert(n < 4611686018427387904ULL); + rv = nghttp3_put_uint64be(p, n); + *p |= 0xC0U; return rv; } -size_t nghttp3_put_varintlen(int64_t n) { +size_t nghttp3_put_uvarintlen(uint64_t n) { if (n < 64) { return 1; } @@ -123,7 +132,7 @@ size_t nghttp3_put_varintlen(int64_t n) { if (n < 1073741824) { return 4; } - assert(n < 4611686018427387904LL); + assert(n < 4611686018427387904ULL); return 8; } diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_conv.h b/deps/ngtcp2/nghttp3/lib/nghttp3_conv.h index f9297994176194..bd6f29a55db569 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_conv.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_conv.h @@ -56,7 +56,7 @@ #include -#define NGHTTP3_VARINT_MAX ((1ull << 62) - 1) +#define NGHTTP3_VARINT_MAX ((1ULL << 62) - 1) #if HAVE_DECL_BE64TOH # define nghttp3_ntohl64(N) be64toh(N) @@ -67,11 +67,11 @@ # define nghttp3_htonl64(N) (N) # else /* !defined(WORDS_BIGENDIAN) */ # if HAVE_DECL_BSWAP_64 -# define nghttp3_bswap64 bswap_64 +# define nghttp3_bswap64(N) bswap_64(N) # elif defined(WIN32) -# define nghttp3_bswap64 _byteswap_uint64 +# define nghttp3_bswap64(N) _byteswap_uint64(N) # elif defined(__APPLE__) -# define nghttp3_bswap64 OSSwapInt64 +# define nghttp3_bswap64(N) OSSwapInt64(N) # else /* !(HAVE_DECL_BSWAP_64 || defined(WIN32) || defined(__APPLE__)) */ # define nghttp3_bswap64(N) \ ((uint64_t)(ntohl((uint32_t)(N))) << 32 | ntohl((uint32_t)((N) >> 32))) @@ -82,52 +82,14 @@ #endif /* !HAVE_DECL_BE64TOH */ #ifdef WIN32 -/* Windows requires ws2_32 library for ntonl family of functions. We - define inline functions for those functions so that we don't have - dependency on that lib. */ - -# ifdef _MSC_VER -# define STIN static __inline -# else /* !defined(_MSC_VER) */ -# define STIN static inline -# endif /* !defined(_MSC_VER) */ - -STIN uint32_t htonl(uint32_t hostlong) { - uint32_t res; - unsigned char *p = (unsigned char *)&res; - *p++ = (unsigned char)(hostlong >> 24); - *p++ = (hostlong >> 16) & 0xffu; - *p++ = (hostlong >> 8) & 0xffu; - *p = hostlong & 0xffu; - return res; -} - -STIN uint16_t htons(uint16_t hostshort) { - uint16_t res; - unsigned char *p = (unsigned char *)&res; - *p++ = (unsigned char)(hostshort >> 8); - *p = hostshort & 0xffu; - return res; -} - -STIN uint32_t ntohl(uint32_t netlong) { - uint32_t res; - unsigned char *p = (unsigned char *)&netlong; - res = (uint32_t)(*p++ << 24); - res += (uint32_t)(*p++ << 16); - res += (uint32_t)(*p++ << 8); - res += *p; - return res; -} - -STIN uint16_t ntohs(uint16_t netshort) { - uint16_t res; - unsigned char *p = (unsigned char *)&netshort; - res = (uint16_t)(*p++ << 8); - res += *p; - return res; -} - +/* Windows requires ws2_32 library for ntonl family of functions. + Instead of using them, use _byteswap_* functions. This is fine + because all platforms that can run Windows these days are little + endian. */ +# define htonl(N) _byteswap_ulong(N) +# define htons(N) _byteswap_ushort(N) +# define ntohl(N) _byteswap_ulong(N) +# define ntohs(N) _byteswap_ushort(N) #endif /* defined(WIN32) */ /* @@ -163,10 +125,4 @@ uint8_t *nghttp3_put_uint16be(uint8_t *p, uint16_t n); */ uint64_t nghttp3_ord_stream_id(int64_t stream_id); -/* - * NGHTTP3_PRI_INC_MASK is a bit mask to retrieve incremental bit from - * a value produced by nghttp3_pri_to_uint8. - */ -#define NGHTTP3_PRI_INC_MASK (1 << 7) - #endif /* !defined(NGHTTP3_CONV_H) */ diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_frame.c b/deps/ngtcp2/nghttp3/lib/nghttp3_frame.c index 608574c4db351e..1742e0756fc665 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_frame.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_frame.c @@ -31,69 +31,70 @@ #include "nghttp3_conv.h" #include "nghttp3_str.h" -uint8_t *nghttp3_frame_write_hd(uint8_t *p, int64_t type, int64_t payloadlen) { - p = nghttp3_put_varint(p, type); - p = nghttp3_put_varint(p, payloadlen); +uint8_t *nghttp3_frame_write_hd(uint8_t *p, uint64_t type, + uint64_t payloadlen) { + p = nghttp3_put_uvarint(p, type); + p = nghttp3_put_uvarint(p, payloadlen); return p; } -size_t nghttp3_frame_write_hd_len(int64_t type, int64_t payloadlen) { - return nghttp3_put_varintlen(type) + nghttp3_put_varintlen(payloadlen); +size_t nghttp3_frame_write_hd_len(uint64_t type, uint64_t payloadlen) { + return nghttp3_put_uvarintlen(type) + nghttp3_put_uvarintlen(payloadlen); } uint8_t *nghttp3_frame_write_settings(uint8_t *p, const nghttp3_frame_settings *fr, - int64_t payloadlen) { + uint64_t payloadlen) { size_t i; p = nghttp3_frame_write_hd(p, fr->type, payloadlen); for (i = 0; i < fr->niv; ++i) { - p = nghttp3_put_varint(p, (int64_t)fr->iv[i].id); - p = nghttp3_put_varint(p, (int64_t)fr->iv[i].value); + p = nghttp3_put_uvarint(p, fr->iv[i].id); + p = nghttp3_put_uvarint(p, fr->iv[i].value); } return p; } -size_t nghttp3_frame_write_settings_len(int64_t *ppayloadlen, +size_t nghttp3_frame_write_settings_len(uint64_t *ppayloadlen, const nghttp3_frame_settings *fr) { size_t payloadlen = 0; size_t i; for (i = 0; i < fr->niv; ++i) { - payloadlen += nghttp3_put_varintlen((int64_t)fr->iv[i].id) + - nghttp3_put_varintlen((int64_t)fr->iv[i].value); + payloadlen += nghttp3_put_uvarintlen(fr->iv[i].id) + + nghttp3_put_uvarintlen(fr->iv[i].value); } - *ppayloadlen = (int64_t)payloadlen; + *ppayloadlen = payloadlen; - return nghttp3_put_varintlen(NGHTTP3_FRAME_SETTINGS) + - nghttp3_put_varintlen((int64_t)payloadlen) + payloadlen; + return nghttp3_put_uvarintlen(NGHTTP3_FRAME_SETTINGS) + + nghttp3_put_uvarintlen(payloadlen) + payloadlen; } uint8_t *nghttp3_frame_write_goaway(uint8_t *p, const nghttp3_frame_goaway *fr, - int64_t payloadlen) { + uint64_t payloadlen) { p = nghttp3_frame_write_hd(p, fr->type, payloadlen); - p = nghttp3_put_varint(p, fr->id); + p = nghttp3_put_uvarint(p, (uint64_t)fr->id); return p; } -size_t nghttp3_frame_write_goaway_len(int64_t *ppayloadlen, +size_t nghttp3_frame_write_goaway_len(uint64_t *ppayloadlen, const nghttp3_frame_goaway *fr) { - size_t payloadlen = nghttp3_put_varintlen(fr->id); + size_t payloadlen = nghttp3_put_uvarintlen((uint64_t)fr->id); - *ppayloadlen = (int64_t)payloadlen; + *ppayloadlen = payloadlen; - return nghttp3_put_varintlen(NGHTTP3_FRAME_GOAWAY) + - nghttp3_put_varintlen((int64_t)payloadlen) + payloadlen; + return nghttp3_put_uvarintlen(NGHTTP3_FRAME_GOAWAY) + + nghttp3_put_uvarintlen(payloadlen) + payloadlen; } uint8_t *nghttp3_frame_write_priority_update( - uint8_t *p, const nghttp3_frame_priority_update *fr, int64_t payloadlen) { + uint8_t *p, const nghttp3_frame_priority_update *fr, uint64_t payloadlen) { p = nghttp3_frame_write_hd(p, fr->type, payloadlen); - p = nghttp3_put_varint(p, fr->pri_elem_id); + p = nghttp3_put_uvarint(p, (uint64_t)fr->pri_elem_id); if (fr->datalen) { p = nghttp3_cpymem(p, fr->data, fr->datalen); } @@ -102,17 +103,18 @@ uint8_t *nghttp3_frame_write_priority_update( } size_t nghttp3_frame_write_priority_update_len( - int64_t *ppayloadlen, const nghttp3_frame_priority_update *fr) { - size_t payloadlen = nghttp3_put_varintlen(fr->pri_elem_id) + fr->datalen; + uint64_t *ppayloadlen, const nghttp3_frame_priority_update *fr) { + size_t payloadlen = + nghttp3_put_uvarintlen((uint64_t)fr->pri_elem_id) + fr->datalen; - *ppayloadlen = (int64_t)payloadlen; + *ppayloadlen = payloadlen; - return nghttp3_put_varintlen(fr->type) + - nghttp3_put_varintlen((int64_t)payloadlen) + payloadlen; + return nghttp3_put_uvarintlen(fr->type) + nghttp3_put_uvarintlen(payloadlen) + + payloadlen; } uint8_t *nghttp3_frame_write_origin(uint8_t *p, const nghttp3_frame_origin *fr, - int64_t payloadlen) { + uint64_t payloadlen) { p = nghttp3_frame_write_hd(p, fr->type, payloadlen); if (fr->origin_list.len) { p = nghttp3_cpymem(p, fr->origin_list.base, fr->origin_list.len); @@ -121,32 +123,33 @@ uint8_t *nghttp3_frame_write_origin(uint8_t *p, const nghttp3_frame_origin *fr, return p; } -size_t nghttp3_frame_write_origin_len(int64_t *ppayloadlen, +size_t nghttp3_frame_write_origin_len(uint64_t *ppayloadlen, const nghttp3_frame_origin *fr) { size_t payloadlen = fr->origin_list.len; - *ppayloadlen = (int64_t)payloadlen; + *ppayloadlen = payloadlen; - return nghttp3_put_varintlen(fr->type) + - nghttp3_put_varintlen((int64_t)payloadlen) + payloadlen; + return nghttp3_put_uvarintlen(fr->type) + nghttp3_put_uvarintlen(payloadlen) + + payloadlen; } uint8_t *nghttp3_frame_write_wt_stream(uint8_t *p, const nghttp3_exfr_wt_stream *fr) { - p = nghttp3_put_varint(p, fr->type); - return nghttp3_put_varint(p, fr->session_id); + p = nghttp3_put_uvarint(p, fr->type); + return nghttp3_put_uvarint(p, (uint64_t)fr->session_id); } size_t nghttp3_frame_write_wt_stream_len(const nghttp3_exfr_wt_stream *fr) { - return nghttp3_put_varintlen(fr->type) + - nghttp3_put_varintlen(fr->session_id); + return nghttp3_put_uvarintlen(fr->type) + + nghttp3_put_uvarintlen((uint64_t)fr->session_id); } uint8_t *nghttp3_frame_write_cpsl_wt_close_session( uint8_t *p, const nghttp3_exfr_cpsl_wt_close_session *fr, - int64_t payloadlen) { + uint64_t payloadlen) { p = nghttp3_frame_write_hd(p, NGHTTP3_FRAME_DATA, payloadlen); - p = nghttp3_frame_write_hd(p, fr->type, sizeof(fr->error_code)); + p = nghttp3_frame_write_hd(p, fr->type, + sizeof(fr->error_code) + fr->error_msg.len); p = nghttp3_put_uint32be(p, fr->error_code); if (fr->error_msg.len) { @@ -157,16 +160,15 @@ uint8_t *nghttp3_frame_write_cpsl_wt_close_session( } size_t nghttp3_frame_write_cpsl_wt_close_session_len( - int64_t *ppayloadlen, const nghttp3_exfr_cpsl_wt_close_session *fr) { + uint64_t *ppayloadlen, const nghttp3_exfr_cpsl_wt_close_session *fr) { size_t cpsl_payloadlen = sizeof(fr->error_code) + fr->error_msg.len; - size_t payloadlen = nghttp3_put_varintlen(fr->type) + - nghttp3_put_varintlen((int64_t)cpsl_payloadlen) + - cpsl_payloadlen; + size_t payloadlen = nghttp3_put_uvarintlen(fr->type) + + nghttp3_put_uvarintlen(cpsl_payloadlen) + cpsl_payloadlen; - *ppayloadlen = (int64_t)payloadlen; + *ppayloadlen = payloadlen; - return nghttp3_put_varintlen(NGHTTP3_FRAME_DATA) + - nghttp3_put_varintlen((int64_t)payloadlen) + payloadlen; + return nghttp3_put_uvarintlen(NGHTTP3_FRAME_DATA) + + nghttp3_put_uvarintlen(payloadlen) + payloadlen; } int nghttp3_nva_copy(nghttp3_nv **pnva, const nghttp3_nv *nva, size_t nvlen, diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_frame.h b/deps/ngtcp2/nghttp3/lib/nghttp3_frame.h index 72f32bf00c4fdf..77b4d37b8fb293 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_frame.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_frame.h @@ -34,79 +34,79 @@ #include "nghttp3_buf.h" -#define NGHTTP3_FRAME_DATA 0x00 -#define NGHTTP3_FRAME_HEADERS 0x01 -#define NGHTTP3_FRAME_CANCEL_PUSH 0x03 -#define NGHTTP3_FRAME_SETTINGS 0x04 -#define NGHTTP3_FRAME_PUSH_PROMISE 0x05 -#define NGHTTP3_FRAME_GOAWAY 0x07 -#define NGHTTP3_FRAME_MAX_PUSH_ID 0x0d +#define NGHTTP3_FRAME_DATA 0x00U +#define NGHTTP3_FRAME_HEADERS 0x01U +#define NGHTTP3_FRAME_CANCEL_PUSH 0x03U +#define NGHTTP3_FRAME_SETTINGS 0x04U +#define NGHTTP3_FRAME_PUSH_PROMISE 0x05U +#define NGHTTP3_FRAME_GOAWAY 0x07U +#define NGHTTP3_FRAME_MAX_PUSH_ID 0x0DU /* PRIORITY_UPDATE: https://datatracker.ietf.org/doc/html/rfc9218 */ -#define NGHTTP3_FRAME_PRIORITY_UPDATE 0x0f0700 -#define NGHTTP3_FRAME_PRIORITY_UPDATE_PUSH_ID 0x0f0701 +#define NGHTTP3_FRAME_PRIORITY_UPDATE 0x0F0700U +#define NGHTTP3_FRAME_PRIORITY_UPDATE_PUSH_ID 0x0F0701U /* ORIGIN: https://datatracker.ietf.org/doc/html/rfc9412 */ -#define NGHTTP3_FRAME_ORIGIN 0x0c +#define NGHTTP3_FRAME_ORIGIN 0x0CU /* WebTransport extended frame type */ -#define NGHTTP3_FRAME_EX_WT 0x4000000000000001 +#define NGHTTP3_FRAME_EX_WT 0x4000000000000001ULL /* WT_STREAM: https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-14 */ -#define NGHTTP3_EXFR_WT_STREAM_BIDI 0x41 -#define NGHTTP3_EXFR_WT_STREAM_UNI 0x54 -#define NGHTTP3_EXFR_WT_STREAM_DATA 0x00 +#define NGHTTP3_EXFR_WT_STREAM_BIDI 0x41U +#define NGHTTP3_EXFR_WT_STREAM_UNI 0x54U +#define NGHTTP3_EXFR_WT_STREAM_DATA 0x00U /* HTTP Capsule extended frame type */ -#define NGHTTP3_FRAME_EX_CPSL 0x4000000000000002 -#define NGHTTP3_EXFR_CPSL_WT_CLOSE_SESSION 0x2843 -#define NGHTTP3_EXFR_CPSL_WT_DRAIN_SESSION 0x78AE -#define NGHTTP3_EXFR_CPSL_WT_MAX_STREAMS_BIDI 0x190B4D3F -#define NGHTTP3_EXFR_CPSL_WT_MAX_STREAMS_UNI 0x190B4D40 -#define NGHTTP3_EXFR_CPSL_WT_STREAMS_BLOCKED_BIDI 0x190B4D43 -#define NGHTTP3_EXFR_CPSL_WT_STREAMS_BLOCKED_UNI 0x190B4D44 -#define NGHTTP3_EXFR_CPSL_WT_MAX_DATA 0x190B4D3D -#define NGHTTP3_EXFR_CPSL_WT_DATA_BLOCKED 0x190B4D41 +#define NGHTTP3_FRAME_EX_CPSL 0x4000000000000002ULL +#define NGHTTP3_EXFR_CPSL_WT_CLOSE_SESSION 0x2843U +#define NGHTTP3_EXFR_CPSL_WT_DRAIN_SESSION 0x78AEU +#define NGHTTP3_EXFR_CPSL_WT_MAX_STREAMS_BIDI 0x190B4D3FU +#define NGHTTP3_EXFR_CPSL_WT_MAX_STREAMS_UNI 0x190B4D40U +#define NGHTTP3_EXFR_CPSL_WT_STREAMS_BLOCKED_BIDI 0x190B4D43U +#define NGHTTP3_EXFR_CPSL_WT_STREAMS_BLOCKED_UNI 0x190B4D44U +#define NGHTTP3_EXFR_CPSL_WT_MAX_DATA 0x190B4D3DU +#define NGHTTP3_EXFR_CPSL_WT_DATA_BLOCKED 0x190B4D41U /* Frame types that are reserved for HTTP/2, and must not be used in HTTP/3. */ -#define NGHTTP3_H2_FRAME_PRIORITY 0x02 -#define NGHTTP3_H2_FRAME_PING 0x06 -#define NGHTTP3_H2_FRAME_WINDOW_UPDATE 0x08 -#define NGHTTP3_H2_FRAME_CONTINUATION 0x9 +#define NGHTTP3_H2_FRAME_PRIORITY 0x02U +#define NGHTTP3_H2_FRAME_PING 0x06U +#define NGHTTP3_H2_FRAME_WINDOW_UPDATE 0x08U +#define NGHTTP3_H2_FRAME_CONTINUATION 0x9U typedef struct nghttp3_frame_hd { - int64_t type; + uint64_t type; } nghttp3_frame_hd; typedef struct nghttp3_frame_data { - int64_t type; + uint64_t type; /* dr is set when sending DATA frame. It is not used on reception. */ nghttp3_data_reader dr; } nghttp3_frame_data; typedef struct nghttp3_frame_headers { - int64_t type; + uint64_t type; nghttp3_nv *nva; size_t nvlen; } nghttp3_frame_headers; -#define NGHTTP3_SETTINGS_ID_MAX_FIELD_SECTION_SIZE 0x06 -#define NGHTTP3_SETTINGS_ID_QPACK_MAX_TABLE_CAPACITY 0x01 -#define NGHTTP3_SETTINGS_ID_QPACK_BLOCKED_STREAMS 0x07 -#define NGHTTP3_SETTINGS_ID_ENABLE_CONNECT_PROTOCOL 0x08 -#define NGHTTP3_SETTINGS_ID_H3_DATAGRAM 0x33 +#define NGHTTP3_SETTINGS_ID_MAX_FIELD_SECTION_SIZE 0x06U +#define NGHTTP3_SETTINGS_ID_QPACK_MAX_TABLE_CAPACITY 0x01U +#define NGHTTP3_SETTINGS_ID_QPACK_BLOCKED_STREAMS 0x07U +#define NGHTTP3_SETTINGS_ID_ENABLE_CONNECT_PROTOCOL 0x08U +#define NGHTTP3_SETTINGS_ID_H3_DATAGRAM 0x33U /* https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-15 */ -#define NGHTTP3_SETTINGS_ID_WT_ENABLED 0x2C7CF000 +#define NGHTTP3_SETTINGS_ID_WT_ENABLED 0x2C7CF000U /* https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-14 */ -#define NGHTTP3_SETTINGS_ID_WT_MAX_SESSIONS 0x14E9CD29 +#define NGHTTP3_SETTINGS_ID_WT_MAX_SESSIONS 0x14E9CD29U /* https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-07 */ -#define NGHTTP3_SETTINGS_ID_WT_MAX_SESSIONS_DRAFT7 0xC671706A +#define NGHTTP3_SETTINGS_ID_WT_MAX_SESSIONS_DRAFT7 0xC671706AU /* https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3-02 */ -#define NGHTTP3_SETTINGS_ID_ENABLE_WEBTRANSPORT_DRAFT2 0x2B603742 +#define NGHTTP3_SETTINGS_ID_ENABLE_WEBTRANSPORT_DRAFT2 0x2B603742U -#define NGHTTP3_H2_SETTINGS_ID_ENABLE_PUSH 0x2 -#define NGHTTP3_H2_SETTINGS_ID_MAX_CONCURRENT_STREAMS 0x3 -#define NGHTTP3_H2_SETTINGS_ID_INITIAL_WINDOW_SIZE 0x4 -#define NGHTTP3_H2_SETTINGS_ID_MAX_FRAME_SIZE 0x5 +#define NGHTTP3_H2_SETTINGS_ID_ENABLE_PUSH 0x2U +#define NGHTTP3_H2_SETTINGS_ID_MAX_CONCURRENT_STREAMS 0x3U +#define NGHTTP3_H2_SETTINGS_ID_INITIAL_WINDOW_SIZE 0x4U +#define NGHTTP3_H2_SETTINGS_ID_MAX_FRAME_SIZE 0x5U typedef struct nghttp3_settings_entry { uint64_t id; @@ -114,7 +114,7 @@ typedef struct nghttp3_settings_entry { } nghttp3_settings_entry; typedef struct nghttp3_frame_settings { - int64_t type; + uint64_t type; size_t niv; nghttp3_settings_entry *iv; /* local_settings is set when sending SETTINGS frame. It is not @@ -123,12 +123,12 @@ typedef struct nghttp3_frame_settings { } nghttp3_frame_settings; typedef struct nghttp3_frame_goaway { - int64_t type; + uint64_t type; int64_t id; } nghttp3_frame_goaway; typedef struct nghttp3_frame_priority_update { - int64_t type; + uint64_t type; /* pri_elem_id is stream ID if type == NGHTTP3_FRAME_PRIORITY_UPDATE. It is push ID if type == NGHTTP3_FRAME_PRIORITY_UPDATE_PUSH_ID. It is undefined @@ -152,18 +152,18 @@ typedef struct nghttp3_frame_priority_update { } nghttp3_frame_priority_update; typedef struct nghttp3_frame_origin { - int64_t type; + uint64_t type; /* These fields are only used by server to send ORIGIN frame. Client never use them. */ nghttp3_vec origin_list; } nghttp3_frame_origin; typedef struct nghttp3_exfr_hd { - int64_t type; + uint64_t type; } nghttp3_exfr_hd; typedef struct nghttp3_exfr_wt_stream { - int64_t type; + uint64_t type; int64_t session_id; nghttp3_data_reader dr; } nghttp3_exfr_wt_stream; @@ -174,12 +174,12 @@ typedef union nghttp3_exfr_wt { } nghttp3_exfr_wt; typedef struct nghttp3_frame_ex_wt { - int64_t type; + uint64_t type; nghttp3_exfr_wt fr; } nghttp3_frame_ex_wt; typedef struct nghttp3_exfr_cpsl_wt_close_session { - int64_t type; + uint64_t type; nghttp3_vec error_msg; uint32_t error_code; } nghttp3_exfr_cpsl_wt_close_session; @@ -190,7 +190,7 @@ typedef union nghttp3_exfr_cpsl { } nghttp3_exfr_cpsl; typedef struct nghttp3_frame_ex_cpsl { - int64_t type; + uint64_t type; nghttp3_exfr_cpsl fr; } nghttp3_frame_ex_cpsl; @@ -213,14 +213,14 @@ typedef union nghttp3_frame { * * This function returns |dest| plus the number of bytes written. */ -uint8_t *nghttp3_frame_write_hd(uint8_t *dest, int64_t type, - int64_t payloadlen); +uint8_t *nghttp3_frame_write_hd(uint8_t *dest, uint64_t type, + uint64_t payloadlen); /* * nghttp3_frame_write_hd_len returns the number of bytes required to * write a frame header consisting of |type| and |payloadlen|. */ -size_t nghttp3_frame_write_hd_len(int64_t type, int64_t payloadlen); +size_t nghttp3_frame_write_hd_len(uint64_t type, uint64_t payloadlen); /* * nghttp3_frame_write_settings writes SETTINGS frame |fr| to |dest|. @@ -231,14 +231,14 @@ size_t nghttp3_frame_write_hd_len(int64_t type, int64_t payloadlen); */ uint8_t *nghttp3_frame_write_settings(uint8_t *dest, const nghttp3_frame_settings *fr, - int64_t payloadlen); + uint64_t payloadlen); /* * nghttp3_frame_write_settings_len returns the number of bytes * required to write |fr|. This function stores the frame payload * length in |*ppayloadlen|. */ -size_t nghttp3_frame_write_settings_len(int64_t *pppayloadlen, +size_t nghttp3_frame_write_settings_len(uint64_t *pppayloadlen, const nghttp3_frame_settings *fr); /* @@ -250,14 +250,14 @@ size_t nghttp3_frame_write_settings_len(int64_t *pppayloadlen, */ uint8_t *nghttp3_frame_write_goaway(uint8_t *dest, const nghttp3_frame_goaway *fr, - int64_t payloadlen); + uint64_t payloadlen); /* * nghttp3_frame_write_goaway_len returns the number of bytes required * to write |fr|. This function stores the frame payload length in * |*ppayloadlen|. */ -size_t nghttp3_frame_write_goaway_len(int64_t *ppayloadlen, +size_t nghttp3_frame_write_goaway_len(uint64_t *ppayloadlen, const nghttp3_frame_goaway *fr); /* @@ -268,7 +268,7 @@ size_t nghttp3_frame_write_goaway_len(int64_t *ppayloadlen, * This function returns |dest| plus the number of bytes written; */ uint8_t *nghttp3_frame_write_priority_update( - uint8_t *dest, const nghttp3_frame_priority_update *fr, int64_t payloadlen); + uint8_t *dest, const nghttp3_frame_priority_update *fr, uint64_t payloadlen); /* * nghttp3_frame_write_priority_update_len returns the number of bytes @@ -276,7 +276,7 @@ uint8_t *nghttp3_frame_write_priority_update( * length in |*ppayloadlen|. */ size_t nghttp3_frame_write_priority_update_len( - int64_t *ppayloadlen, const nghttp3_frame_priority_update *fr); + uint64_t *ppayloadlen, const nghttp3_frame_priority_update *fr); /* * nghttp3_frame_write_origin writes ORIGIN frame |fr| to |dest|. @@ -287,14 +287,14 @@ size_t nghttp3_frame_write_priority_update_len( */ uint8_t *nghttp3_frame_write_origin(uint8_t *dest, const nghttp3_frame_origin *fr, - int64_t payloadlen); + uint64_t payloadlen); /* * nghttp3_frame_write_origin_len returns the number of bytes required * to write |fr|. This function stores the frame payload length in * |*ppayloadlen|. */ -size_t nghttp3_frame_write_origin_len(int64_t *ppayloadlen, +size_t nghttp3_frame_write_origin_len(uint64_t *ppayloadlen, const nghttp3_frame_origin *fr); uint8_t *nghttp3_frame_write_wt_stream(uint8_t *dest, @@ -304,10 +304,10 @@ size_t nghttp3_frame_write_wt_stream_len(const nghttp3_exfr_wt_stream *fr); uint8_t *nghttp3_frame_write_cpsl_wt_close_session( uint8_t *dest, const nghttp3_exfr_cpsl_wt_close_session *fr, - int64_t payloadlen); + uint64_t payloadlen); size_t nghttp3_frame_write_cpsl_wt_close_session_len( - int64_t *ppayloadlen, const nghttp3_exfr_cpsl_wt_close_session *fr); + uint64_t *ppayloadlen, const nghttp3_exfr_cpsl_wt_close_session *fr); /* * nghttp3_nva_copy copies name/value pairs from |nva|, which contains diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_gaptr.c b/deps/ngtcp2/nghttp3/lib/nghttp3_gaptr.c index 68a4f8f747d682..bd557d08c34d51 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_gaptr.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_gaptr.c @@ -36,11 +36,11 @@ void nghttp3_gaptr_init(nghttp3_gaptr *gaptr, const nghttp3_mem *mem) { } static int gaptr_gap_init(nghttp3_gaptr *gaptr) { - return nghttp3_ksl_insert(&gaptr->gap, NULL, - &(nghttp3_range){ - .end = UINT64_MAX, - }, - NULL); + static const nghttp3_range end = { + .end = UINT64_MAX, + }; + + return nghttp3_ksl_insert(&gaptr->gap, NULL, &end, NULL); } void nghttp3_gaptr_free(nghttp3_gaptr *gaptr) { diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_http.c b/deps/ngtcp2/nghttp3/lib/nghttp3_http.c index 41cfe74440a3d2..e2725308e5daab 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_http.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_http.c @@ -62,27 +62,39 @@ static int memieq(const void *a, const void *b, size_t n) { #define lstrieq(A, B, N) \ (nghttp3_strlen_lit((A)) == (N) && memieq((A), (B), (N))) +static int32_t parse_status_code(const uint8_t *s, size_t len) { + if (len != 3 || '1' > s[0] || s[0] > '9' || '0' > s[1] || s[1] > '9' || + '0' > s[2] || s[2] > '9') { + return -1; + } + + return (s[0] - '0') * 100 + (s[1] - '0') * 10 + (s[2] - '0'); +} + static int64_t parse_uint(const uint8_t *s, size_t len) { - int64_t n = 0; + uint64_t n = 0; + uint32_t c; size_t i; + if (len == 0) { return -1; } + for (i = 0; i < len; ++i) { - if ('0' <= s[i] && s[i] <= '9') { - if (n > (int64_t)NGHTTP3_MAX_VARINT / 10) { - return -1; - } - n *= 10; - if (n > (int64_t)NGHTTP3_MAX_VARINT - (s[i] - '0')) { - return -1; - } - n += s[i] - '0'; - continue; + if ('0' > s[i] || s[i] > '9') { + return -1; } - return -1; + + c = s[i] - '0'; + + if (n > (NGHTTP3_MAX_VARINT - c) / 10) { + return -1; + } + + n = n * 10 + c; } - return n; + + return (int64_t)n; } static int check_pseudo_header(nghttp3_http_state *http, @@ -94,7 +106,7 @@ static int check_pseudo_header(nghttp3_http_state *http, return 1; } -static int expect_response_body(nghttp3_http_state *http) { +static int expect_response_body(const nghttp3_http_state *http) { return (http->flags & NGHTTP3_HTTP_FLAG_METH_HEAD) == 0 && http->status_code / 100 != 1 && http->status_code != 304 && http->status_code != 204; @@ -105,7 +117,7 @@ static int expect_response_body(nghttp3_http_state *http) { :path header field value must start with "/". This function must be called after ":method" header field was received. This function returns nonzero if path is valid.*/ -static int check_path_flags(nghttp3_http_state *http) { +static int check_path_flags(const nghttp3_http_state *http) { return (http->flags & NGHTTP3_HTTP_FLAG_SCHEME_HTTP) == 0 || ((http->flags & NGHTTP3_HTTP_FLAG_PATH_REGULAR) || ((http->flags & NGHTTP3_HTTP_FLAG_METH_OPTIONS) && @@ -275,26 +287,26 @@ static const int8_t VALID_PATH_CHARS[256] = { ['u'] = 1, ['v'] = 1, ['w'] = 1, ['x'] = 1, ['y'] = 1, ['z'] = 1, ['{'] = 1, ['|'] = 1, ['}'] = 1, ['~'] = 1, [0x80] = 1, [0x81] = 1, [0x82] = 1, [0x83] = 1, [0x84] = 1, [0x85] = 1, [0x86] = 1, [0x87] = 1, - [0x88] = 1, [0x89] = 1, [0x8a] = 1, [0x8b] = 1, [0x8c] = 1, [0x8d] = 1, - [0x8e] = 1, [0x8f] = 1, [0x90] = 1, [0x91] = 1, [0x92] = 1, [0x93] = 1, + [0x88] = 1, [0x89] = 1, [0x8A] = 1, [0x8B] = 1, [0x8C] = 1, [0x8D] = 1, + [0x8E] = 1, [0x8F] = 1, [0x90] = 1, [0x91] = 1, [0x92] = 1, [0x93] = 1, [0x94] = 1, [0x95] = 1, [0x96] = 1, [0x97] = 1, [0x98] = 1, [0x99] = 1, - [0x9a] = 1, [0x9b] = 1, [0x9c] = 1, [0x9d] = 1, [0x9e] = 1, [0x9f] = 1, - [0xa0] = 1, [0xa1] = 1, [0xa2] = 1, [0xa3] = 1, [0xa4] = 1, [0xa5] = 1, - [0xa6] = 1, [0xa7] = 1, [0xa8] = 1, [0xa9] = 1, [0xaa] = 1, [0xab] = 1, - [0xac] = 1, [0xad] = 1, [0xae] = 1, [0xaf] = 1, [0xb0] = 1, [0xb1] = 1, - [0xb2] = 1, [0xb3] = 1, [0xb4] = 1, [0xb5] = 1, [0xb6] = 1, [0xb7] = 1, - [0xb8] = 1, [0xb9] = 1, [0xba] = 1, [0xbb] = 1, [0xbc] = 1, [0xbd] = 1, - [0xbe] = 1, [0xbf] = 1, [0xc0] = 1, [0xc1] = 1, [0xc2] = 1, [0xc3] = 1, - [0xc4] = 1, [0xc5] = 1, [0xc6] = 1, [0xc7] = 1, [0xc8] = 1, [0xc9] = 1, - [0xca] = 1, [0xcb] = 1, [0xcc] = 1, [0xcd] = 1, [0xce] = 1, [0xcf] = 1, - [0xd0] = 1, [0xd1] = 1, [0xd2] = 1, [0xd3] = 1, [0xd4] = 1, [0xd5] = 1, - [0xd6] = 1, [0xd7] = 1, [0xd8] = 1, [0xd9] = 1, [0xda] = 1, [0xdb] = 1, - [0xdc] = 1, [0xdd] = 1, [0xde] = 1, [0xdf] = 1, [0xe0] = 1, [0xe1] = 1, - [0xe2] = 1, [0xe3] = 1, [0xe4] = 1, [0xe5] = 1, [0xe6] = 1, [0xe7] = 1, - [0xe8] = 1, [0xe9] = 1, [0xea] = 1, [0xeb] = 1, [0xec] = 1, [0xed] = 1, - [0xee] = 1, [0xef] = 1, [0xf0] = 1, [0xf1] = 1, [0xf2] = 1, [0xf3] = 1, - [0xf4] = 1, [0xf5] = 1, [0xf6] = 1, [0xf7] = 1, [0xf8] = 1, [0xf9] = 1, - [0xfa] = 1, [0xfb] = 1, [0xfc] = 1, [0xfd] = 1, [0xfe] = 1, [0xff] = 1, + [0x9A] = 1, [0x9B] = 1, [0x9C] = 1, [0x9D] = 1, [0x9E] = 1, [0x9F] = 1, + [0xA0] = 1, [0xA1] = 1, [0xA2] = 1, [0xA3] = 1, [0xA4] = 1, [0xA5] = 1, + [0xA6] = 1, [0xA7] = 1, [0xA8] = 1, [0xA9] = 1, [0xAA] = 1, [0xAB] = 1, + [0xAC] = 1, [0xAD] = 1, [0xAE] = 1, [0xAF] = 1, [0xB0] = 1, [0xB1] = 1, + [0xB2] = 1, [0xB3] = 1, [0xB4] = 1, [0xB5] = 1, [0xB6] = 1, [0xB7] = 1, + [0xB8] = 1, [0xB9] = 1, [0xBA] = 1, [0xBB] = 1, [0xBC] = 1, [0xBD] = 1, + [0xBE] = 1, [0xBF] = 1, [0xC0] = 1, [0xC1] = 1, [0xC2] = 1, [0xC3] = 1, + [0xC4] = 1, [0xC5] = 1, [0xC6] = 1, [0xC7] = 1, [0xC8] = 1, [0xC9] = 1, + [0xCA] = 1, [0xCB] = 1, [0xCC] = 1, [0xCD] = 1, [0xCE] = 1, [0xCF] = 1, + [0xD0] = 1, [0xD1] = 1, [0xD2] = 1, [0xD3] = 1, [0xD4] = 1, [0xD5] = 1, + [0xD6] = 1, [0xD7] = 1, [0xD8] = 1, [0xD9] = 1, [0xDA] = 1, [0xDB] = 1, + [0xDC] = 1, [0xDD] = 1, [0xDE] = 1, [0xDF] = 1, [0xE0] = 1, [0xE1] = 1, + [0xE2] = 1, [0xE3] = 1, [0xE4] = 1, [0xE5] = 1, [0xE6] = 1, [0xE7] = 1, + [0xE8] = 1, [0xE9] = 1, [0xEA] = 1, [0xEB] = 1, [0xEC] = 1, [0xED] = 1, + [0xEE] = 1, [0xEF] = 1, [0xF0] = 1, [0xF1] = 1, [0xF2] = 1, [0xF3] = 1, + [0xF4] = 1, [0xF5] = 1, [0xF6] = 1, [0xF7] = 1, [0xF8] = 1, [0xF9] = 1, + [0xFA] = 1, [0xFB] = 1, [0xFC] = 1, [0xFD] = 1, [0xFE] = 1, [0xFF] = 1, }; static int check_path(const uint8_t *value, size_t len) { @@ -308,7 +320,7 @@ static int check_path(const uint8_t *value, size_t len) { } static int http_request_on_header(nghttp3_http_state *http, - nghttp3_qpack_nv *nv, int trailers, + const nghttp3_qpack_nv *nv, int trailers, int connect_protocol) { nghttp3_pri pri; @@ -457,15 +469,14 @@ static int http_request_on_header(nghttp3_http_state *http, } static int http_response_on_header(nghttp3_http_state *http, - nghttp3_qpack_nv *nv, int trailers) { + const nghttp3_qpack_nv *nv, int trailers) { switch (nv->token) { case NGHTTP3_QPACK_TOKEN__STATUS: { - if (!check_pseudo_header(http, nv, NGHTTP3_HTTP_FLAG__STATUS) || - nv->value->len != 3) { + if (!check_pseudo_header(http, nv, NGHTTP3_HTTP_FLAG__STATUS)) { return NGHTTP3_ERR_MALFORMED_HTTP_HEADER; } - http->status_code = (int16_t)parse_uint(nv->value->base, nv->value->len); - if (http->status_code < 100 || http->status_code == 101) { + http->status_code = parse_status_code(nv->value->base, nv->value->len); + if (http->status_code == -1 || http->status_code == 101) { return NGHTTP3_ERR_MALFORMED_HTTP_HEADER; } break; @@ -532,7 +543,7 @@ static int http_response_on_header(nghttp3_http_state *http, static int http_check_nonempty_header_name(const uint8_t *name, size_t len); -int nghttp3_http_on_header(nghttp3_http_state *http, nghttp3_qpack_nv *nv, +int nghttp3_http_on_header(nghttp3_http_state *http, const nghttp3_qpack_nv *nv, int request, int trailers, int connect_protocol) { if (nv->name->len == 0) { http->flags |= NGHTTP3_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED; @@ -582,10 +593,13 @@ int nghttp3_http_on_request_headers(nghttp3_http_state *http) { (NGHTTP3_HTTP_FLAG__AUTHORITY | NGHTTP3_HTTP_FLAG_HOST)) == 0) { return NGHTTP3_ERR_MALFORMED_HTTP_HEADER; } - if ((http->flags & NGHTTP3_HTTP_FLAG__PROTOCOL) && - ((http->flags & NGHTTP3_HTTP_FLAG_METH_CONNECT) == 0 || - (http->flags & NGHTTP3_HTTP_FLAG__AUTHORITY) == 0)) { - return NGHTTP3_ERR_MALFORMED_HTTP_HEADER; + if (http->flags & NGHTTP3_HTTP_FLAG__PROTOCOL) { + if ((http->flags & NGHTTP3_HTTP_FLAG_METH_CONNECT) == 0 || + (http->flags & NGHTTP3_HTTP_FLAG__AUTHORITY) == 0) { + return NGHTTP3_ERR_MALFORMED_HTTP_HEADER; + } + + http->content_length = -1; } if (!check_path_flags(http)) { return NGHTTP3_ERR_MALFORMED_HTTP_HEADER; @@ -620,7 +634,7 @@ int nghttp3_http_on_response_headers(nghttp3_http_state *http) { return 0; } -int nghttp3_http_on_remote_end_stream(nghttp3_stream *stream) { +int nghttp3_http_on_remote_end_stream(const nghttp3_stream *stream) { if ((stream->rx.http.flags & NGHTTP3_HTTP_FLAG_EXPECT_FINAL_RESPONSE) || (stream->rx.http.content_length != -1 && stream->rx.http.content_length != stream->rx.http.recv_content_length)) { @@ -738,36 +752,36 @@ static const int8_t VALID_HD_VALUE_CHARS[256] = { ['s'] = 1, ['t'] = 1, ['u'] = 1, ['v'] = 1, ['w'] = 1, ['x'] = 1, ['y'] = 1, ['z'] = 1, ['{'] = 1, ['|'] = 1, ['}'] = 1, ['~'] = 1, [0x80] = 1, [0x81] = 1, [0x82] = 1, [0x83] = 1, [0x84] = 1, [0x85] = 1, - [0x86] = 1, [0x87] = 1, [0x88] = 1, [0x89] = 1, [0x8a] = 1, [0x8b] = 1, - [0x8c] = 1, [0x8d] = 1, [0x8e] = 1, [0x8f] = 1, [0x90] = 1, [0x91] = 1, + [0x86] = 1, [0x87] = 1, [0x88] = 1, [0x89] = 1, [0x8A] = 1, [0x8B] = 1, + [0x8C] = 1, [0x8D] = 1, [0x8E] = 1, [0x8F] = 1, [0x90] = 1, [0x91] = 1, [0x92] = 1, [0x93] = 1, [0x94] = 1, [0x95] = 1, [0x96] = 1, [0x97] = 1, - [0x98] = 1, [0x99] = 1, [0x9a] = 1, [0x9b] = 1, [0x9c] = 1, [0x9d] = 1, - [0x9e] = 1, [0x9f] = 1, [0xa0] = 1, [0xa1] = 1, [0xa2] = 1, [0xa3] = 1, - [0xa4] = 1, [0xa5] = 1, [0xa6] = 1, [0xa7] = 1, [0xa8] = 1, [0xa9] = 1, - [0xaa] = 1, [0xab] = 1, [0xac] = 1, [0xad] = 1, [0xae] = 1, [0xaf] = 1, - [0xb0] = 1, [0xb1] = 1, [0xb2] = 1, [0xb3] = 1, [0xb4] = 1, [0xb5] = 1, - [0xb6] = 1, [0xb7] = 1, [0xb8] = 1, [0xb9] = 1, [0xba] = 1, [0xbb] = 1, - [0xbc] = 1, [0xbd] = 1, [0xbe] = 1, [0xbf] = 1, [0xc0] = 1, [0xc1] = 1, - [0xc2] = 1, [0xc3] = 1, [0xc4] = 1, [0xc5] = 1, [0xc6] = 1, [0xc7] = 1, - [0xc8] = 1, [0xc9] = 1, [0xca] = 1, [0xcb] = 1, [0xcc] = 1, [0xcd] = 1, - [0xce] = 1, [0xcf] = 1, [0xd0] = 1, [0xd1] = 1, [0xd2] = 1, [0xd3] = 1, - [0xd4] = 1, [0xd5] = 1, [0xd6] = 1, [0xd7] = 1, [0xd8] = 1, [0xd9] = 1, - [0xda] = 1, [0xdb] = 1, [0xdc] = 1, [0xdd] = 1, [0xde] = 1, [0xdf] = 1, - [0xe0] = 1, [0xe1] = 1, [0xe2] = 1, [0xe3] = 1, [0xe4] = 1, [0xe5] = 1, - [0xe6] = 1, [0xe7] = 1, [0xe8] = 1, [0xe9] = 1, [0xea] = 1, [0xeb] = 1, - [0xec] = 1, [0xed] = 1, [0xee] = 1, [0xef] = 1, [0xf0] = 1, [0xf1] = 1, - [0xf2] = 1, [0xf3] = 1, [0xf4] = 1, [0xf5] = 1, [0xf6] = 1, [0xf7] = 1, - [0xf8] = 1, [0xf9] = 1, [0xfa] = 1, [0xfb] = 1, [0xfc] = 1, [0xfd] = 1, - [0xfe] = 1, [0xff] = 1, + [0x98] = 1, [0x99] = 1, [0x9A] = 1, [0x9B] = 1, [0x9C] = 1, [0x9D] = 1, + [0x9E] = 1, [0x9F] = 1, [0xA0] = 1, [0xA1] = 1, [0xA2] = 1, [0xA3] = 1, + [0xA4] = 1, [0xA5] = 1, [0xA6] = 1, [0xA7] = 1, [0xA8] = 1, [0xA9] = 1, + [0xAA] = 1, [0xAB] = 1, [0xAC] = 1, [0xAD] = 1, [0xAE] = 1, [0xAF] = 1, + [0xB0] = 1, [0xB1] = 1, [0xB2] = 1, [0xB3] = 1, [0xB4] = 1, [0xB5] = 1, + [0xB6] = 1, [0xB7] = 1, [0xB8] = 1, [0xB9] = 1, [0xBA] = 1, [0xBB] = 1, + [0xBC] = 1, [0xBD] = 1, [0xBE] = 1, [0xBF] = 1, [0xC0] = 1, [0xC1] = 1, + [0xC2] = 1, [0xC3] = 1, [0xC4] = 1, [0xC5] = 1, [0xC6] = 1, [0xC7] = 1, + [0xC8] = 1, [0xC9] = 1, [0xCA] = 1, [0xCB] = 1, [0xCC] = 1, [0xCD] = 1, + [0xCE] = 1, [0xCF] = 1, [0xD0] = 1, [0xD1] = 1, [0xD2] = 1, [0xD3] = 1, + [0xD4] = 1, [0xD5] = 1, [0xD6] = 1, [0xD7] = 1, [0xD8] = 1, [0xD9] = 1, + [0xDA] = 1, [0xDB] = 1, [0xDC] = 1, [0xDD] = 1, [0xDE] = 1, [0xDF] = 1, + [0xE0] = 1, [0xE1] = 1, [0xE2] = 1, [0xE3] = 1, [0xE4] = 1, [0xE5] = 1, + [0xE6] = 1, [0xE7] = 1, [0xE8] = 1, [0xE9] = 1, [0xEA] = 1, [0xEB] = 1, + [0xEC] = 1, [0xED] = 1, [0xEE] = 1, [0xEF] = 1, [0xF0] = 1, [0xF1] = 1, + [0xF2] = 1, [0xF3] = 1, [0xF4] = 1, [0xF5] = 1, [0xF6] = 1, [0xF7] = 1, + [0xF8] = 1, [0xF9] = 1, [0xFA] = 1, [0xFB] = 1, [0xFC] = 1, [0xFD] = 1, + [0xFE] = 1, [0xFF] = 1, }; #ifdef __AVX2__ static int contains_bad_header_value_char_avx2(const uint8_t *first, const uint8_t *last) { const __m256i ctll = _mm256_set1_epi8(0x00 - 1); - const __m256i ctlr = _mm256_set1_epi8(0x1f + 1); + const __m256i ctlr = _mm256_set1_epi8(0x1F + 1); const __m256i ht = _mm256_set1_epi8('\t'); - const __m256i del = _mm256_set1_epi8(0x7f); + const __m256i del = _mm256_set1_epi8(0x7F); __m256i s, x; uint32_t m; @@ -814,7 +828,7 @@ int nghttp3_check_header_value(const uint8_t *value, size_t len) { #ifdef __AVX2__ if (len >= 32) { - last32 = value + (len & ~0x1fu); + last32 = value + (len & ~(size_t)0x1FU); if (contains_bad_header_value_char_avx2(value, last32)) { return 0; } diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_http.h b/deps/ngtcp2/nghttp3/lib/nghttp3_http.h index 89532b1c5805c0..ec32414c1d1d5a 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_http.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_http.h @@ -39,48 +39,48 @@ typedef struct nghttp3_http_state nghttp3_http_state; /* HTTP related flags to enforce HTTP semantics */ /* NGHTTP3_HTTP_FLAG_NONE indicates that no flag is set. */ -#define NGHTTP3_HTTP_FLAG_NONE 0x00u +#define NGHTTP3_HTTP_FLAG_NONE 0x00U /* header field seen so far */ -#define NGHTTP3_HTTP_FLAG__AUTHORITY 0x01u -#define NGHTTP3_HTTP_FLAG__PATH 0x02u -#define NGHTTP3_HTTP_FLAG__METHOD 0x04u -#define NGHTTP3_HTTP_FLAG__SCHEME 0x08u +#define NGHTTP3_HTTP_FLAG__AUTHORITY 0x01U +#define NGHTTP3_HTTP_FLAG__PATH 0x02U +#define NGHTTP3_HTTP_FLAG__METHOD 0x04U +#define NGHTTP3_HTTP_FLAG__SCHEME 0x08U /* host is not pseudo header, but we require either host or :authority */ -#define NGHTTP3_HTTP_FLAG_HOST 0x10u -#define NGHTTP3_HTTP_FLAG__STATUS 0x20u +#define NGHTTP3_HTTP_FLAG_HOST 0x10U +#define NGHTTP3_HTTP_FLAG__STATUS 0x20U /* required header fields for HTTP request except for CONNECT method. */ #define NGHTTP3_HTTP_FLAG_REQ_HEADERS \ (NGHTTP3_HTTP_FLAG__METHOD | NGHTTP3_HTTP_FLAG__PATH | \ NGHTTP3_HTTP_FLAG__SCHEME) -#define NGHTTP3_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED 0x40u +#define NGHTTP3_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED 0x40U /* HTTP method flags */ -#define NGHTTP3_HTTP_FLAG_METH_CONNECT 0x80u -#define NGHTTP3_HTTP_FLAG_METH_HEAD 0x0100u -#define NGHTTP3_HTTP_FLAG_METH_OPTIONS 0x0200u +#define NGHTTP3_HTTP_FLAG_METH_CONNECT 0x80U +#define NGHTTP3_HTTP_FLAG_METH_HEAD 0x0100U +#define NGHTTP3_HTTP_FLAG_METH_OPTIONS 0x0200U #define NGHTTP3_HTTP_FLAG_METH_ALL \ (NGHTTP3_HTTP_FLAG_METH_CONNECT | NGHTTP3_HTTP_FLAG_METH_HEAD | \ NGHTTP3_HTTP_FLAG_METH_OPTIONS) /* :path category */ /* path starts with "/" */ -#define NGHTTP3_HTTP_FLAG_PATH_REGULAR 0x0400u +#define NGHTTP3_HTTP_FLAG_PATH_REGULAR 0x0400U /* path "*" */ -#define NGHTTP3_HTTP_FLAG_PATH_ASTERISK 0x0800u +#define NGHTTP3_HTTP_FLAG_PATH_ASTERISK 0x0800U /* scheme */ /* "http" or "https" scheme */ -#define NGHTTP3_HTTP_FLAG_SCHEME_HTTP 0x1000u +#define NGHTTP3_HTTP_FLAG_SCHEME_HTTP 0x1000U /* set if final response is expected */ -#define NGHTTP3_HTTP_FLAG_EXPECT_FINAL_RESPONSE 0x2000u +#define NGHTTP3_HTTP_FLAG_EXPECT_FINAL_RESPONSE 0x2000U /* NGHTTP3_HTTP_FLAG__PROTOCOL is set when :protocol pseudo header field is seen. */ -#define NGHTTP3_HTTP_FLAG__PROTOCOL 0x4000u +#define NGHTTP3_HTTP_FLAG__PROTOCOL 0x4000U /* NGHTTP3_HTTP_FLAG_PRIORITY is set when priority header field is processed. */ -#define NGHTTP3_HTTP_FLAG_PRIORITY 0x8000u +#define NGHTTP3_HTTP_FLAG_PRIORITY 0x8000U /* NGHTTP3_HTTP_FLAG_BAD_PRIORITY is set when an error is encountered while parsing priority header field. */ -#define NGHTTP3_HTTP_FLAG_BAD_PRIORITY 0x010000u +#define NGHTTP3_HTTP_FLAG_BAD_PRIORITY 0x010000U #define NGHTTP3_HTTP_FLAG_WEBTRANSPORT 0x020000U @@ -100,7 +100,7 @@ typedef struct nghttp3_http_state nghttp3_http_state; * Invalid HTTP header field was received but it can be treated as * if it was not received because of compatibility reasons. */ -int nghttp3_http_on_header(nghttp3_http_state *http, nghttp3_qpack_nv *nv, +int nghttp3_http_on_header(nghttp3_http_state *http, const nghttp3_qpack_nv *nv, int request, int trailers, int connect_protocol); /* @@ -133,7 +133,7 @@ int nghttp3_http_on_response_headers(nghttp3_http_state *http); * NGHTTP3_ERR_MALFORMED_HTTP_MESSAGING * HTTP messaging is violated. */ -int nghttp3_http_on_remote_end_stream(nghttp3_stream *stream); +int nghttp3_http_on_remote_end_stream(const nghttp3_stream *stream); /* * This function is called when chunk of data is received. This diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_ksl.c b/deps/ngtcp2/nghttp3/lib/nghttp3_ksl.c index fa5d7fdc1c8799..efb4f958a85eb5 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_ksl.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_ksl.c @@ -32,7 +32,6 @@ #include "nghttp3_macro.h" #include "nghttp3_mem.h" -#include "nghttp3_range.h" static nghttp3_ksl_blk null_blk; @@ -57,13 +56,12 @@ void nghttp3_ksl_init(nghttp3_ksl *ksl, nghttp3_ksl_compar compar, assert(keylen >= sizeof(uint64_t)); - aligned_keylen = (keylen + 0x7u) & ~0x7u; + aligned_keylen = (keylen + 0x7U) & ~(size_t)0x7U; assert(aligned_keylen <= UINT16_MAX); - nghttp3_objalloc_init(&ksl->blkalloc, - (ksl_blklen(aligned_keylen) + 0xfu) & ~(uintptr_t)0xfu, - mem); + nghttp3_objalloc_init( + &ksl->blkalloc, (ksl_blklen(aligned_keylen) + 0xFU) & ~(size_t)0xFU, mem); ksl->root = NULL; ksl->front = ksl->back = NULL; @@ -817,12 +815,6 @@ int nghttp3_ksl_it_begin(const nghttp3_ksl_it *it) { return it->i == 0 && it->blk->prev == NULL; } -int nghttp3_ksl_range_compar(const nghttp3_ksl_key *lhs, - const nghttp3_ksl_key *rhs) { - const nghttp3_range *a = lhs, *b = rhs; - return a->begin < b->begin; -} - nghttp3_ksl_search_def(range, nghttp3_ksl_range_compar) size_t nghttp3_ksl_range_search(const nghttp3_ksl *ksl, nghttp3_ksl_blk *blk, @@ -830,13 +822,6 @@ size_t nghttp3_ksl_range_search(const nghttp3_ksl *ksl, nghttp3_ksl_blk *blk, return ksl_range_search(ksl, blk, key); } -int nghttp3_ksl_range_exclusive_compar(const nghttp3_ksl_key *lhs, - const nghttp3_ksl_key *rhs) { - const nghttp3_range *a = lhs, *b = rhs; - return a->begin < b->begin && !(nghttp3_max_uint64(a->begin, b->begin) < - nghttp3_min_uint64(a->end, b->end)); -} - nghttp3_ksl_search_def(range_exclusive, nghttp3_ksl_range_exclusive_compar) size_t nghttp3_ksl_range_exclusive_search(const nghttp3_ksl *ksl, @@ -845,11 +830,6 @@ size_t nghttp3_ksl_range_exclusive_search(const nghttp3_ksl *ksl, return ksl_range_exclusive_search(ksl, blk, key); } -int nghttp3_ksl_uint64_less(const nghttp3_ksl_key *lhs, - const nghttp3_ksl_key *rhs) { - return *(uint64_t *)lhs < *(uint64_t *)rhs; -} - nghttp3_ksl_search_def(uint64_less, nghttp3_ksl_uint64_less) size_t nghttp3_ksl_uint64_less_search(const nghttp3_ksl *ksl, @@ -858,11 +838,6 @@ size_t nghttp3_ksl_uint64_less_search(const nghttp3_ksl *ksl, return ksl_uint64_less_search(ksl, blk, key); } -int nghttp3_ksl_int64_greater(const nghttp3_ksl_key *lhs, - const nghttp3_ksl_key *rhs) { - return *(int64_t *)lhs > *(int64_t *)rhs; -} - nghttp3_ksl_search_def(int64_greater, nghttp3_ksl_int64_greater) size_t nghttp3_ksl_int64_greater_search(const nghttp3_ksl *ksl, diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_ksl.h b/deps/ngtcp2/nghttp3/lib/nghttp3_ksl.h index 022cd172a37e67..852e4d471f23d7 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_ksl.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_ksl.h @@ -35,6 +35,7 @@ #include #include "nghttp3_objalloc.h" +#include "nghttp3_range.h" #define NGHTTP3_KSL_DEGR 16 /* NGHTTP3_KSL_MAX_NBLK is the maximum number of nodes which a single @@ -360,8 +361,12 @@ nghttp3_ksl_it_key(const nghttp3_ksl_it *it) { * object, and the function returns nonzero if ((const nghttp3_range * *)lhs)->begin < ((const nghttp3_range *)rhs)->begin. */ -int nghttp3_ksl_range_compar(const nghttp3_ksl_key *lhs, - const nghttp3_ksl_key *rhs); +static inline int nghttp3_ksl_range_compar(const nghttp3_ksl_key *lhs, + const nghttp3_ksl_key *rhs) { + const nghttp3_range *a = (const nghttp3_range *)lhs, + *b = (const nghttp3_range *)rhs; + return a->begin < b->begin; +} /* * nghttp3_ksl_range_search is an implementation of nghttp3_ksl_search @@ -377,8 +382,14 @@ size_t nghttp3_ksl_range_search(const nghttp3_ksl *ksl, nghttp3_ksl_blk *blk, * *)lhs)->begin < ((const nghttp3_range *)rhs)->begin, and the 2 * ranges do not intersect. */ -int nghttp3_ksl_range_exclusive_compar(const nghttp3_ksl_key *lhs, - const nghttp3_ksl_key *rhs); +static inline int +nghttp3_ksl_range_exclusive_compar(const nghttp3_ksl_key *lhs, + const nghttp3_ksl_key *rhs) { + const nghttp3_range *a = (const nghttp3_range *)lhs, + *b = (const nghttp3_range *)rhs; + return a->begin < b->begin && + !(nghttp3_max(a->begin, b->begin) < nghttp3_min(a->end, b->end)); +} /* * nghttp3_ksl_range_exclusive_search is an implementation of @@ -393,8 +404,10 @@ size_t nghttp3_ksl_range_exclusive_search(const nghttp3_ksl *ksl, * |lhs| and |rhs| must point to uint64_t objects, and the function * returns nonzero if *(uint64_t *)|lhs| < *(uint64_t *)|rhs|. */ -int nghttp3_ksl_uint64_less(const nghttp3_ksl_key *lhs, - const nghttp3_ksl_key *rhs); +static inline int nghttp3_ksl_uint64_less(const nghttp3_ksl_key *lhs, + const nghttp3_ksl_key *rhs) { + return *(const uint64_t *)lhs < *(const uint64_t *)rhs; +} /* * nghttp3_ksl_uint64_less_search is an implementation of @@ -410,8 +423,10 @@ size_t nghttp3_ksl_uint64_less_search(const nghttp3_ksl *ksl, * and the function returns nonzero if *(int64_t *)|lhs| > *(int64_t * *)|rhs|. */ -int nghttp3_ksl_int64_greater(const nghttp3_ksl_key *lhs, - const nghttp3_ksl_key *rhs); +static inline int nghttp3_ksl_int64_greater(const nghttp3_ksl_key *lhs, + const nghttp3_ksl_key *rhs) { + return *(const int64_t *)lhs > *(const int64_t *)rhs; +} /* * nghttp3_ksl_int64_greater_search is an implementation of diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_macro.h b/deps/ngtcp2/nghttp3/lib/nghttp3_macro.h index 58a7dfd27570c5..2b03dc53dbb7a0 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_macro.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_macro.h @@ -56,27 +56,81 @@ #define nghttp3_max_def(SUFFIX, T) \ static inline T nghttp3_max_##SUFFIX(T a, T b) { return a < b ? b : a; } -nghttp3_max_def(int8, int8_t) -nghttp3_max_def(int16, int16_t) -nghttp3_max_def(int32, int32_t) -nghttp3_max_def(int64, int64_t) -nghttp3_max_def(uint8, uint8_t) -nghttp3_max_def(uint16, uint16_t) -nghttp3_max_def(uint32, uint32_t) -nghttp3_max_def(uint64, uint64_t) -nghttp3_max_def(size, size_t) +nghttp3_max_def(long_long_int, long long int) +nghttp3_max_def(long_int, long int) +nghttp3_max_def(int, int) +nghttp3_max_def(short_int, short int) +nghttp3_max_def(signed_char, signed char) +nghttp3_max_def(char, char) +nghttp3_max_def(unsigned_long_long_int, unsigned long long int) +nghttp3_max_def(unsigned_long_int, unsigned long int) +nghttp3_max_def(unsigned_int, unsigned int) +nghttp3_max_def(unsigned_short_int, unsigned short int) +nghttp3_max_def(unsigned_char, unsigned char) + +#define nghttp3_max(A, B) \ + _Generic((A), \ + long long int: nghttp3_max_long_long_int, \ + long int: nghttp3_max_long_int, \ + int: _Generic((B), \ + long long int: nghttp3_max_long_long_int, \ + long int: nghttp3_max_long_int, \ + int: nghttp3_max_int, \ + short int: nghttp3_max_short_int, \ + signed char: nghttp3_max_signed_char, \ + char: nghttp3_max_char, \ + unsigned long long int: nghttp3_max_unsigned_long_long_int, \ + unsigned long int: nghttp3_max_unsigned_long_int, \ + unsigned int: nghttp3_max_unsigned_int, \ + unsigned short int: nghttp3_max_unsigned_short_int, \ + unsigned char: nghttp3_max_unsigned_char), \ + short int: nghttp3_max_short_int, \ + signed char: nghttp3_max_signed_char, \ + char: nghttp3_max_char, \ + unsigned long long int: nghttp3_max_unsigned_long_long_int, \ + unsigned long int: nghttp3_max_unsigned_long_int, \ + unsigned int: nghttp3_max_unsigned_int, \ + unsigned short int: nghttp3_max_unsigned_short_int, \ + unsigned char: nghttp3_max_unsigned_char)((A), (B)) #define nghttp3_min_def(SUFFIX, T) \ static inline T nghttp3_min_##SUFFIX(T a, T b) { return a < b ? a : b; } -nghttp3_min_def(int8, int8_t) -nghttp3_min_def(int16, int16_t) -nghttp3_min_def(int32, int32_t) -nghttp3_min_def(int64, int64_t) -nghttp3_min_def(uint8, uint8_t) -nghttp3_min_def(uint16, uint16_t) -nghttp3_min_def(uint32, uint32_t) -nghttp3_min_def(uint64, uint64_t) -nghttp3_min_def(size, size_t) +nghttp3_min_def(long_long_int, long long int) +nghttp3_min_def(long_int, long int) +nghttp3_min_def(int, int) +nghttp3_min_def(short_int, short int) +nghttp3_min_def(signed_char, signed char) +nghttp3_min_def(char, char) +nghttp3_min_def(unsigned_long_long_int, unsigned long long int) +nghttp3_min_def(unsigned_long_int, unsigned long int) +nghttp3_min_def(unsigned_int, unsigned int) +nghttp3_min_def(unsigned_short_int, unsigned short int) +nghttp3_min_def(unsigned_char, unsigned char) + +#define nghttp3_min(A, B) \ + _Generic((A), \ + long long int: nghttp3_min_long_long_int, \ + long int: nghttp3_min_long_int, \ + int: _Generic((B), \ + long long int: nghttp3_min_long_long_int, \ + long int: nghttp3_min_long_int, \ + int: nghttp3_min_int, \ + short int: nghttp3_min_short_int, \ + signed char: nghttp3_min_signed_char, \ + char: nghttp3_min_char, \ + unsigned long long int: nghttp3_min_unsigned_long_long_int, \ + unsigned long int: nghttp3_min_unsigned_long_int, \ + unsigned int: nghttp3_min_unsigned_int, \ + unsigned short int: nghttp3_min_unsigned_short_int, \ + unsigned char: nghttp3_min_unsigned_char), \ + short int: nghttp3_min_short_int, \ + signed char: nghttp3_min_signed_char, \ + char: nghttp3_min_char, \ + unsigned long long int: nghttp3_min_unsigned_long_long_int, \ + unsigned long int: nghttp3_min_unsigned_long_int, \ + unsigned int: nghttp3_min_unsigned_int, \ + unsigned short int: nghttp3_min_unsigned_short_int, \ + unsigned char: nghttp3_min_unsigned_char)((A), (B)) #endif /* !defined(NGHTTP3_MACRO_H) */ diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_map.c b/deps/ngtcp2/nghttp3/lib/nghttp3_map.c index d5b720b148f89a..7858d4cc3eb10b 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_map.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_map.c @@ -78,10 +78,10 @@ int nghttp3_map_each(const nghttp3_map *map, int (*func)(void *data, void *ptr), /* Hasher from https://github.com/rust-lang/rustc-hash/blob/dc5c33f1283de2da64d8d7a06401d91aded03ad4/src/lib.rs to maximize the output's sensitivity to all input bits. */ -#define NGHTTP3_MAP_HASHER 0xf1357aea2e62a9c5ull +#define NGHTTP3_MAP_HASHER 0xF1357AEA2E62A9C5ULL /* 64-bit Fibonacci hashing constant, Golden Ratio constant, to get the high bits with the good distribution. */ -#define NGHTTP3_MAP_FIBO 0x9e3779b97f4a7c15ull +#define NGHTTP3_MAP_FIBO 0x9E3779B97F4A7C15ULL static size_t map_index(const nghttp3_map *map, nghttp3_map_key_type key) { key += map->seed; diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_objalloc.h b/deps/ngtcp2/nghttp3/lib/nghttp3_objalloc.h index 4f8ffa093751a7..b3c17046607218 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_objalloc.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_objalloc.h @@ -70,7 +70,7 @@ void nghttp3_objalloc_clear(nghttp3_objalloc *objalloc); inline static void nghttp3_objalloc_##NAME##_init( \ nghttp3_objalloc *objalloc, size_t nmemb, const nghttp3_mem *mem) { \ nghttp3_objalloc_init( \ - objalloc, ((sizeof(TYPE) + 0xfu) & ~(uintptr_t)0xfu) * nmemb, mem); \ + objalloc, ((sizeof(TYPE) + 0xFU) & ~(size_t)0xFU) * nmemb, mem); \ } \ \ TYPE *nghttp3_objalloc_##NAME##_get(nghttp3_objalloc *objalloc); \ @@ -124,7 +124,7 @@ void nghttp3_objalloc_clear(nghttp3_objalloc *objalloc); inline static void nghttp3_objalloc_##NAME##_init( \ nghttp3_objalloc *objalloc, size_t nmemb, const nghttp3_mem *mem) { \ nghttp3_objalloc_init( \ - objalloc, ((sizeof(TYPE) + 0xfu) & ~(uintptr_t)0xfu) * nmemb, mem); \ + objalloc, ((sizeof(TYPE) + 0xFU) & ~(size_t)0xFU) * nmemb, mem); \ } \ \ inline static TYPE *nghttp3_objalloc_##NAME##_get( \ diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_pq.c b/deps/ngtcp2/nghttp3/lib/nghttp3_pq.c index e35bcac4e43b8f..c5b657bc6d9fb3 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_pq.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_pq.c @@ -76,7 +76,7 @@ int nghttp3_pq_push(nghttp3_pq *pq, nghttp3_pq_entry *item) { void *nq; size_t ncapacity; - ncapacity = nghttp3_max_size(4, pq->capacity * 2); + ncapacity = nghttp3_max(4, pq->capacity * 2); nq = nghttp3_mem_realloc(pq->mem, pq->q, ncapacity * sizeof(nghttp3_pq_entry *)); diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_qpack.c b/deps/ngtcp2/nghttp3/lib/nghttp3_qpack.c index 30f2cdd719c87c..59b633ea057254 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_qpack.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_qpack.c @@ -50,122 +50,122 @@ /* Generated by mkstatichdtbl.py */ static nghttp3_qpack_static_entry token_stable[] = { - MAKE_STATIC_ENT(0, NGHTTP3_QPACK_TOKEN__AUTHORITY, 3153725150u), - MAKE_STATIC_ENT(15, NGHTTP3_QPACK_TOKEN__METHOD, 695666056u), - MAKE_STATIC_ENT(16, NGHTTP3_QPACK_TOKEN__METHOD, 695666056u), - MAKE_STATIC_ENT(17, NGHTTP3_QPACK_TOKEN__METHOD, 695666056u), - MAKE_STATIC_ENT(18, NGHTTP3_QPACK_TOKEN__METHOD, 695666056u), - MAKE_STATIC_ENT(19, NGHTTP3_QPACK_TOKEN__METHOD, 695666056u), - MAKE_STATIC_ENT(20, NGHTTP3_QPACK_TOKEN__METHOD, 695666056u), - MAKE_STATIC_ENT(21, NGHTTP3_QPACK_TOKEN__METHOD, 695666056u), - MAKE_STATIC_ENT(1, NGHTTP3_QPACK_TOKEN__PATH, 3292848686u), - MAKE_STATIC_ENT(22, NGHTTP3_QPACK_TOKEN__SCHEME, 2510477674u), - MAKE_STATIC_ENT(23, NGHTTP3_QPACK_TOKEN__SCHEME, 2510477674u), - MAKE_STATIC_ENT(24, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(25, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(26, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(27, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(28, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(63, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(64, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(65, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(66, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(67, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(68, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(69, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(70, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(71, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983u), - MAKE_STATIC_ENT(29, NGHTTP3_QPACK_TOKEN_ACCEPT, 136609321u), - MAKE_STATIC_ENT(30, NGHTTP3_QPACK_TOKEN_ACCEPT, 136609321u), - MAKE_STATIC_ENT(31, NGHTTP3_QPACK_TOKEN_ACCEPT_ENCODING, 3379649177u), - MAKE_STATIC_ENT(72, NGHTTP3_QPACK_TOKEN_ACCEPT_LANGUAGE, 1979086614u), - MAKE_STATIC_ENT(32, NGHTTP3_QPACK_TOKEN_ACCEPT_RANGES, 1713753958u), + MAKE_STATIC_ENT(0, NGHTTP3_QPACK_TOKEN__AUTHORITY, 3153725150U), + MAKE_STATIC_ENT(15, NGHTTP3_QPACK_TOKEN__METHOD, 695666056U), + MAKE_STATIC_ENT(16, NGHTTP3_QPACK_TOKEN__METHOD, 695666056U), + MAKE_STATIC_ENT(17, NGHTTP3_QPACK_TOKEN__METHOD, 695666056U), + MAKE_STATIC_ENT(18, NGHTTP3_QPACK_TOKEN__METHOD, 695666056U), + MAKE_STATIC_ENT(19, NGHTTP3_QPACK_TOKEN__METHOD, 695666056U), + MAKE_STATIC_ENT(20, NGHTTP3_QPACK_TOKEN__METHOD, 695666056U), + MAKE_STATIC_ENT(21, NGHTTP3_QPACK_TOKEN__METHOD, 695666056U), + MAKE_STATIC_ENT(1, NGHTTP3_QPACK_TOKEN__PATH, 3292848686U), + MAKE_STATIC_ENT(22, NGHTTP3_QPACK_TOKEN__SCHEME, 2510477674U), + MAKE_STATIC_ENT(23, NGHTTP3_QPACK_TOKEN__SCHEME, 2510477674U), + MAKE_STATIC_ENT(24, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(25, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(26, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(27, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(28, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(63, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(64, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(65, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(66, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(67, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(68, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(69, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(70, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(71, NGHTTP3_QPACK_TOKEN__STATUS, 4000288983U), + MAKE_STATIC_ENT(29, NGHTTP3_QPACK_TOKEN_ACCEPT, 136609321U), + MAKE_STATIC_ENT(30, NGHTTP3_QPACK_TOKEN_ACCEPT, 136609321U), + MAKE_STATIC_ENT(31, NGHTTP3_QPACK_TOKEN_ACCEPT_ENCODING, 3379649177U), + MAKE_STATIC_ENT(72, NGHTTP3_QPACK_TOKEN_ACCEPT_LANGUAGE, 1979086614U), + MAKE_STATIC_ENT(32, NGHTTP3_QPACK_TOKEN_ACCEPT_RANGES, 1713753958U), MAKE_STATIC_ENT(73, NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_CREDENTIALS, - 901040780u), + 901040780U), MAKE_STATIC_ENT(74, NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_CREDENTIALS, - 901040780u), + 901040780U), MAKE_STATIC_ENT(33, NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_HEADERS, - 1524311232u), + 1524311232U), MAKE_STATIC_ENT(34, NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_HEADERS, - 1524311232u), + 1524311232U), MAKE_STATIC_ENT(75, NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_HEADERS, - 1524311232u), + 1524311232U), MAKE_STATIC_ENT(76, NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_METHODS, - 2175229868u), + 2175229868U), MAKE_STATIC_ENT(77, NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_METHODS, - 2175229868u), + 2175229868U), MAKE_STATIC_ENT(78, NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_METHODS, - 2175229868u), + 2175229868U), MAKE_STATIC_ENT(35, NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_ORIGIN, - 2710797292u), + 2710797292U), MAKE_STATIC_ENT(79, NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_EXPOSE_HEADERS, - 2449824425u), + 2449824425U), MAKE_STATIC_ENT(80, NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_REQUEST_HEADERS, - 3599549072u), + 3599549072U), MAKE_STATIC_ENT(81, NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_REQUEST_METHOD, - 2417078055u), + 2417078055U), MAKE_STATIC_ENT(82, NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_REQUEST_METHOD, - 2417078055u), - MAKE_STATIC_ENT(2, NGHTTP3_QPACK_TOKEN_AGE, 742476188u), - MAKE_STATIC_ENT(83, NGHTTP3_QPACK_TOKEN_ALT_SVC, 2148877059u), - MAKE_STATIC_ENT(84, NGHTTP3_QPACK_TOKEN_AUTHORIZATION, 2436257726u), - MAKE_STATIC_ENT(36, NGHTTP3_QPACK_TOKEN_CACHE_CONTROL, 1355326669u), - MAKE_STATIC_ENT(37, NGHTTP3_QPACK_TOKEN_CACHE_CONTROL, 1355326669u), - MAKE_STATIC_ENT(38, NGHTTP3_QPACK_TOKEN_CACHE_CONTROL, 1355326669u), - MAKE_STATIC_ENT(39, NGHTTP3_QPACK_TOKEN_CACHE_CONTROL, 1355326669u), - MAKE_STATIC_ENT(40, NGHTTP3_QPACK_TOKEN_CACHE_CONTROL, 1355326669u), - MAKE_STATIC_ENT(41, NGHTTP3_QPACK_TOKEN_CACHE_CONTROL, 1355326669u), - MAKE_STATIC_ENT(3, NGHTTP3_QPACK_TOKEN_CONTENT_DISPOSITION, 3889184348u), - MAKE_STATIC_ENT(42, NGHTTP3_QPACK_TOKEN_CONTENT_ENCODING, 65203592u), - MAKE_STATIC_ENT(43, NGHTTP3_QPACK_TOKEN_CONTENT_ENCODING, 65203592u), - MAKE_STATIC_ENT(4, NGHTTP3_QPACK_TOKEN_CONTENT_LENGTH, 1308181789u), - MAKE_STATIC_ENT(85, NGHTTP3_QPACK_TOKEN_CONTENT_SECURITY_POLICY, 1569039836u), - MAKE_STATIC_ENT(44, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277u), - MAKE_STATIC_ENT(45, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277u), - MAKE_STATIC_ENT(46, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277u), - MAKE_STATIC_ENT(47, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277u), - MAKE_STATIC_ENT(48, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277u), - MAKE_STATIC_ENT(49, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277u), - MAKE_STATIC_ENT(50, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277u), - MAKE_STATIC_ENT(51, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277u), - MAKE_STATIC_ENT(52, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277u), - MAKE_STATIC_ENT(53, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277u), - MAKE_STATIC_ENT(54, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277u), - MAKE_STATIC_ENT(5, NGHTTP3_QPACK_TOKEN_COOKIE, 2007449791u), - MAKE_STATIC_ENT(6, NGHTTP3_QPACK_TOKEN_DATE, 3564297305u), - MAKE_STATIC_ENT(86, NGHTTP3_QPACK_TOKEN_EARLY_DATA, 4080895051u), - MAKE_STATIC_ENT(7, NGHTTP3_QPACK_TOKEN_ETAG, 113792960u), - MAKE_STATIC_ENT(87, NGHTTP3_QPACK_TOKEN_EXPECT_CT, 1183214960u), - MAKE_STATIC_ENT(88, NGHTTP3_QPACK_TOKEN_FORWARDED, 1485178027u), - MAKE_STATIC_ENT(8, NGHTTP3_QPACK_TOKEN_IF_MODIFIED_SINCE, 2213050793u), - MAKE_STATIC_ENT(9, NGHTTP3_QPACK_TOKEN_IF_NONE_MATCH, 2536202615u), - MAKE_STATIC_ENT(89, NGHTTP3_QPACK_TOKEN_IF_RANGE, 2340978238u), - MAKE_STATIC_ENT(10, NGHTTP3_QPACK_TOKEN_LAST_MODIFIED, 3226950251u), - MAKE_STATIC_ENT(11, NGHTTP3_QPACK_TOKEN_LINK, 232457833u), - MAKE_STATIC_ENT(12, NGHTTP3_QPACK_TOKEN_LOCATION, 200649126u), - MAKE_STATIC_ENT(90, NGHTTP3_QPACK_TOKEN_ORIGIN, 3649018447u), - MAKE_STATIC_ENT(91, NGHTTP3_QPACK_TOKEN_PURPOSE, 4212263681u), - MAKE_STATIC_ENT(55, NGHTTP3_QPACK_TOKEN_RANGE, 4208725202u), - MAKE_STATIC_ENT(13, NGHTTP3_QPACK_TOKEN_REFERER, 3969579366u), - MAKE_STATIC_ENT(92, NGHTTP3_QPACK_TOKEN_SERVER, 1085029842u), - MAKE_STATIC_ENT(14, NGHTTP3_QPACK_TOKEN_SET_COOKIE, 1848371000u), + 2417078055U), + MAKE_STATIC_ENT(2, NGHTTP3_QPACK_TOKEN_AGE, 742476188U), + MAKE_STATIC_ENT(83, NGHTTP3_QPACK_TOKEN_ALT_SVC, 2148877059U), + MAKE_STATIC_ENT(84, NGHTTP3_QPACK_TOKEN_AUTHORIZATION, 2436257726U), + MAKE_STATIC_ENT(36, NGHTTP3_QPACK_TOKEN_CACHE_CONTROL, 1355326669U), + MAKE_STATIC_ENT(37, NGHTTP3_QPACK_TOKEN_CACHE_CONTROL, 1355326669U), + MAKE_STATIC_ENT(38, NGHTTP3_QPACK_TOKEN_CACHE_CONTROL, 1355326669U), + MAKE_STATIC_ENT(39, NGHTTP3_QPACK_TOKEN_CACHE_CONTROL, 1355326669U), + MAKE_STATIC_ENT(40, NGHTTP3_QPACK_TOKEN_CACHE_CONTROL, 1355326669U), + MAKE_STATIC_ENT(41, NGHTTP3_QPACK_TOKEN_CACHE_CONTROL, 1355326669U), + MAKE_STATIC_ENT(3, NGHTTP3_QPACK_TOKEN_CONTENT_DISPOSITION, 3889184348U), + MAKE_STATIC_ENT(42, NGHTTP3_QPACK_TOKEN_CONTENT_ENCODING, 65203592U), + MAKE_STATIC_ENT(43, NGHTTP3_QPACK_TOKEN_CONTENT_ENCODING, 65203592U), + MAKE_STATIC_ENT(4, NGHTTP3_QPACK_TOKEN_CONTENT_LENGTH, 1308181789U), + MAKE_STATIC_ENT(85, NGHTTP3_QPACK_TOKEN_CONTENT_SECURITY_POLICY, 1569039836U), + MAKE_STATIC_ENT(44, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277U), + MAKE_STATIC_ENT(45, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277U), + MAKE_STATIC_ENT(46, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277U), + MAKE_STATIC_ENT(47, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277U), + MAKE_STATIC_ENT(48, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277U), + MAKE_STATIC_ENT(49, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277U), + MAKE_STATIC_ENT(50, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277U), + MAKE_STATIC_ENT(51, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277U), + MAKE_STATIC_ENT(52, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277U), + MAKE_STATIC_ENT(53, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277U), + MAKE_STATIC_ENT(54, NGHTTP3_QPACK_TOKEN_CONTENT_TYPE, 4244048277U), + MAKE_STATIC_ENT(5, NGHTTP3_QPACK_TOKEN_COOKIE, 2007449791U), + MAKE_STATIC_ENT(6, NGHTTP3_QPACK_TOKEN_DATE, 3564297305U), + MAKE_STATIC_ENT(86, NGHTTP3_QPACK_TOKEN_EARLY_DATA, 4080895051U), + MAKE_STATIC_ENT(7, NGHTTP3_QPACK_TOKEN_ETAG, 113792960U), + MAKE_STATIC_ENT(87, NGHTTP3_QPACK_TOKEN_EXPECT_CT, 1183214960U), + MAKE_STATIC_ENT(88, NGHTTP3_QPACK_TOKEN_FORWARDED, 1485178027U), + MAKE_STATIC_ENT(8, NGHTTP3_QPACK_TOKEN_IF_MODIFIED_SINCE, 2213050793U), + MAKE_STATIC_ENT(9, NGHTTP3_QPACK_TOKEN_IF_NONE_MATCH, 2536202615U), + MAKE_STATIC_ENT(89, NGHTTP3_QPACK_TOKEN_IF_RANGE, 2340978238U), + MAKE_STATIC_ENT(10, NGHTTP3_QPACK_TOKEN_LAST_MODIFIED, 3226950251U), + MAKE_STATIC_ENT(11, NGHTTP3_QPACK_TOKEN_LINK, 232457833U), + MAKE_STATIC_ENT(12, NGHTTP3_QPACK_TOKEN_LOCATION, 200649126U), + MAKE_STATIC_ENT(90, NGHTTP3_QPACK_TOKEN_ORIGIN, 3649018447U), + MAKE_STATIC_ENT(91, NGHTTP3_QPACK_TOKEN_PURPOSE, 4212263681U), + MAKE_STATIC_ENT(55, NGHTTP3_QPACK_TOKEN_RANGE, 4208725202U), + MAKE_STATIC_ENT(13, NGHTTP3_QPACK_TOKEN_REFERER, 3969579366U), + MAKE_STATIC_ENT(92, NGHTTP3_QPACK_TOKEN_SERVER, 1085029842U), + MAKE_STATIC_ENT(14, NGHTTP3_QPACK_TOKEN_SET_COOKIE, 1848371000U), MAKE_STATIC_ENT(56, NGHTTP3_QPACK_TOKEN_STRICT_TRANSPORT_SECURITY, - 4138147361u), + 4138147361U), MAKE_STATIC_ENT(57, NGHTTP3_QPACK_TOKEN_STRICT_TRANSPORT_SECURITY, - 4138147361u), + 4138147361U), MAKE_STATIC_ENT(58, NGHTTP3_QPACK_TOKEN_STRICT_TRANSPORT_SECURITY, - 4138147361u), - MAKE_STATIC_ENT(93, NGHTTP3_QPACK_TOKEN_TIMING_ALLOW_ORIGIN, 2432297564u), + 4138147361U), + MAKE_STATIC_ENT(93, NGHTTP3_QPACK_TOKEN_TIMING_ALLOW_ORIGIN, 2432297564U), MAKE_STATIC_ENT(94, NGHTTP3_QPACK_TOKEN_UPGRADE_INSECURE_REQUESTS, - 2479169413u), - MAKE_STATIC_ENT(95, NGHTTP3_QPACK_TOKEN_USER_AGENT, 606444526u), - MAKE_STATIC_ENT(59, NGHTTP3_QPACK_TOKEN_VARY, 1085005381u), - MAKE_STATIC_ENT(60, NGHTTP3_QPACK_TOKEN_VARY, 1085005381u), - MAKE_STATIC_ENT(61, NGHTTP3_QPACK_TOKEN_X_CONTENT_TYPE_OPTIONS, 3644557769u), - MAKE_STATIC_ENT(96, NGHTTP3_QPACK_TOKEN_X_FORWARDED_FOR, 2914187656u), - MAKE_STATIC_ENT(97, NGHTTP3_QPACK_TOKEN_X_FRAME_OPTIONS, 3993834824u), - MAKE_STATIC_ENT(98, NGHTTP3_QPACK_TOKEN_X_FRAME_OPTIONS, 3993834824u), - MAKE_STATIC_ENT(62, NGHTTP3_QPACK_TOKEN_X_XSS_PROTECTION, 2501058888u), + 2479169413U), + MAKE_STATIC_ENT(95, NGHTTP3_QPACK_TOKEN_USER_AGENT, 606444526U), + MAKE_STATIC_ENT(59, NGHTTP3_QPACK_TOKEN_VARY, 1085005381U), + MAKE_STATIC_ENT(60, NGHTTP3_QPACK_TOKEN_VARY, 1085005381U), + MAKE_STATIC_ENT(61, NGHTTP3_QPACK_TOKEN_X_CONTENT_TYPE_OPTIONS, 3644557769U), + MAKE_STATIC_ENT(96, NGHTTP3_QPACK_TOKEN_X_FORWARDED_FOR, 2914187656U), + MAKE_STATIC_ENT(97, NGHTTP3_QPACK_TOKEN_X_FRAME_OPTIONS, 3993834824U), + MAKE_STATIC_ENT(98, NGHTTP3_QPACK_TOKEN_X_FRAME_OPTIONS, 3993834824U), + MAKE_STATIC_ENT(62, NGHTTP3_QPACK_TOKEN_X_XSS_PROTECTION, 2501058888U), }; /* Make scalar initialization form of nghttp3_qpack_static_entry */ @@ -749,7 +749,7 @@ static int qpack_nv_value_eq(const nghttp3_qpack_nv *a, const nghttp3_nv *b) { } static void qpack_map_init(nghttp3_qpack_map *map) { - memset(map, 0, sizeof(nghttp3_qpack_map)); + *map = (nghttp3_qpack_map){0}; } static void qpack_map_insert(nghttp3_qpack_map *map, nghttp3_qpack_entry *ent) { @@ -940,8 +940,8 @@ void nghttp3_qpack_encoder_free(nghttp3_qpack_encoder *encoder) { void nghttp3_qpack_encoder_set_max_dtable_capacity( nghttp3_qpack_encoder *encoder, size_t max_dtable_capacity) { - max_dtable_capacity = nghttp3_min_size(max_dtable_capacity, - encoder->ctx.hard_max_dtable_capacity); + max_dtable_capacity = + nghttp3_min(max_dtable_capacity, encoder->ctx.hard_max_dtable_capacity); if (encoder->ctx.max_dtable_capacity == max_dtable_capacity) { return; @@ -966,7 +966,8 @@ void nghttp3_qpack_encoder_set_indexing_strat( encoder->indexing_strat = strat; } -uint64_t nghttp3_qpack_encoder_get_min_cnt(nghttp3_qpack_encoder *encoder) { +uint64_t +nghttp3_qpack_encoder_get_min_cnt(const nghttp3_qpack_encoder *encoder) { assert(!nghttp3_pq_empty(&encoder->min_cnts)); return nghttp3_struct_of(nghttp3_pq_top(&encoder->min_cnts), @@ -1111,15 +1112,15 @@ static int reserve_buf(nghttp3_buf *buf, size_t extra_size, return 0; } - n = nghttp3_max_size(n, nghttp3_buf_cap(buf) + extra_size - left); + n = nghttp3_max(n, nghttp3_buf_cap(buf) + extra_size - left); /* Check whether we are requesting too much memory */ - if (n > (1u << 31)) { + if (n > (1U << 31)) { return NGHTTP3_ERR_NOMEM; } #ifndef WIN32 - n = 1u << (32 - __builtin_clz((uint32_t)n - 1)); + n = 1U << (32 - __builtin_clz((uint32_t)n - 1)); #else /* defined(WIN32) */ /* Round up to the next highest power of 2 from Bit Twiddling Hacks */ @@ -1271,23 +1272,23 @@ int nghttp3_qpack_encoder_process_dtable_update(nghttp3_qpack_encoder *encoder, int nghttp3_qpack_encoder_write_set_dtable_cap(nghttp3_qpack_encoder *encoder, nghttp3_buf *ebuf, size_t cap) { DEBUGF("qpack::encode: Set Dynamic Table Capacity capacity=%zu\n", cap); - return qpack_write_number(ebuf, 0x20, cap, 5, encoder->ctx.mem); + return qpack_write_number(ebuf, 0x20U, cap, 5, encoder->ctx.mem); } nghttp3_qpack_stream * -nghttp3_qpack_encoder_find_stream(nghttp3_qpack_encoder *encoder, +nghttp3_qpack_encoder_find_stream(const nghttp3_qpack_encoder *encoder, int64_t stream_id) { return nghttp3_map_find(&encoder->streams, (nghttp3_map_key_type)stream_id); } -int nghttp3_qpack_encoder_stream_is_blocked(nghttp3_qpack_encoder *encoder, - nghttp3_qpack_stream *stream) { +int nghttp3_qpack_encoder_stream_is_blocked( + const nghttp3_qpack_encoder *encoder, const nghttp3_qpack_stream *stream) { return stream && encoder->krcnt < nghttp3_qpack_stream_get_max_cnt(stream); } static uint32_t qpack_hash_name(const nghttp3_nv *nv) { /* 32 bit FNV-1a: http://isthe.com/chongo/tech/comp/fnv/ */ - uint32_t h = 2166136261u; + uint32_t h = 2166136261U; size_t i; for (i = 0; i < nv->namelen; ++i) { @@ -1304,7 +1305,7 @@ static uint32_t qpack_hash_name(const nghttp3_nv *nv) { * name. */ static nghttp3_qpack_indexing_mode -qpack_encoder_decide_indexing_mode(nghttp3_qpack_encoder *encoder, +qpack_encoder_decide_indexing_mode(const nghttp3_qpack_encoder *encoder, const nghttp3_nv *nv, int32_t token) { if (nv->flags & NGHTTP3_NV_FLAG_NEVER_INDEX) { return NGHTTP3_QPACK_INDEXING_MODE_NEVER; @@ -1391,7 +1392,7 @@ static int qpack_encoder_can_index(nghttp3_qpack_encoder *encoder, size_t need, if (!nghttp3_pq_empty(&encoder->min_cnts)) { gmin_cnt = nghttp3_qpack_encoder_get_min_cnt(encoder); - min_cnt = nghttp3_min_uint64(min_cnt, gmin_cnt); + min_cnt = nghttp3_min(min_cnt, gmin_cnt); } if (min_cnt == UINT64_MAX) { @@ -1445,7 +1446,7 @@ static int qpack_encoder_can_index_duplicate(nghttp3_qpack_encoder *encoder, static int qpack_context_check_draining(nghttp3_qpack_context *ctx, uint64_t absidx) { const size_t safe = ctx->max_dtable_capacity - - nghttp3_min_size(512, ctx->max_dtable_capacity * 1 / 8); + nghttp3_min(512, ctx->max_dtable_capacity * 1 / 8); nghttp3_qpack_entry *ent = nghttp3_qpack_context_dtable_get(ctx, absidx); return ctx->dtable_sum - ent->sum > safe; @@ -1490,16 +1491,16 @@ int nghttp3_qpack_encoder_encode_nv(nghttp3_qpack_encoder *encoder, } else { switch (token) { case NGHTTP3_QPACK_TOKEN_HOST: - hash = 2952701295u; + hash = 2952701295U; break; case NGHTTP3_QPACK_TOKEN_TE: - hash = 1011170994u; + hash = 1011170994U; break; case NGHTTP3_QPACK_TOKEN__PROTOCOL: - hash = 1128642621u; + hash = 1128642621U; break; case NGHTTP3_QPACK_TOKEN_PRIORITY: - hash = 2498028297u; + hash = 2498028297U; break; default: hash = qpack_hash_name(nv); @@ -1532,8 +1533,8 @@ int nghttp3_qpack_encoder_encode_nv(nghttp3_qpack_encoder *encoder, new_ent = nghttp3_qpack_context_dtable_top(&encoder->ctx); dres.index = (nghttp3_ssize)new_ent->absidx; } - *pmax_cnt = nghttp3_max_uint64(*pmax_cnt, (uint64_t)(dres.index + 1)); - *pmin_cnt = nghttp3_min_uint64(*pmin_cnt, (uint64_t)(dres.index + 1)); + *pmax_cnt = nghttp3_max(*pmax_cnt, (uint64_t)(dres.index + 1)); + *pmin_cnt = nghttp3_min(*pmin_cnt, (uint64_t)(dres.index + 1)); return nghttp3_qpack_encoder_write_dynamic_indexed( encoder, rbuf, (size_t)dres.index, base); @@ -1553,8 +1554,8 @@ int nghttp3_qpack_encoder_encode_nv(nghttp3_qpack_encoder *encoder, } if (allow_blocking) { new_ent = nghttp3_qpack_context_dtable_top(&encoder->ctx); - *pmax_cnt = nghttp3_max_uint64(*pmax_cnt, new_ent->absidx + 1); - *pmin_cnt = nghttp3_min_uint64(*pmin_cnt, new_ent->absidx + 1); + *pmax_cnt = nghttp3_max(*pmax_cnt, new_ent->absidx + 1); + *pmin_cnt = nghttp3_min(*pmin_cnt, new_ent->absidx + 1); return nghttp3_qpack_encoder_write_dynamic_indexed( encoder, rbuf, new_ent->absidx, base); @@ -1569,9 +1570,8 @@ int nghttp3_qpack_encoder_encode_nv(nghttp3_qpack_encoder *encoder, if (just_index && qpack_encoder_can_index_nv( encoder, nv, - allow_blocking - ? *pmin_cnt - : nghttp3_min_uint64((uint64_t)dres.index + 1, *pmin_cnt))) { + allow_blocking ? *pmin_cnt + : nghttp3_min((uint64_t)dres.index + 1, *pmin_cnt))) { rv = nghttp3_qpack_encoder_write_dynamic_insert(encoder, ebuf, (size_t)dres.index, nv); if (rv != 0) { @@ -1579,7 +1579,7 @@ int nghttp3_qpack_encoder_encode_nv(nghttp3_qpack_encoder *encoder, } if (!allow_blocking) { - *pmin_cnt = nghttp3_min_uint64(*pmin_cnt, (uint64_t)dres.index + 1); + *pmin_cnt = nghttp3_min(*pmin_cnt, (uint64_t)dres.index + 1); } rv = nghttp3_qpack_encoder_dtable_dynamic_add(encoder, (size_t)dres.index, @@ -1590,16 +1590,16 @@ int nghttp3_qpack_encoder_encode_nv(nghttp3_qpack_encoder *encoder, if (allow_blocking) { new_ent = nghttp3_qpack_context_dtable_top(&encoder->ctx); - *pmax_cnt = nghttp3_max_uint64(*pmax_cnt, new_ent->absidx + 1); - *pmin_cnt = nghttp3_min_uint64(*pmin_cnt, new_ent->absidx + 1); + *pmax_cnt = nghttp3_max(*pmax_cnt, new_ent->absidx + 1); + *pmin_cnt = nghttp3_min(*pmin_cnt, new_ent->absidx + 1); return nghttp3_qpack_encoder_write_dynamic_indexed( encoder, rbuf, new_ent->absidx, base); } } - *pmax_cnt = nghttp3_max_uint64(*pmax_cnt, (uint64_t)(dres.index + 1)); - *pmin_cnt = nghttp3_min_uint64(*pmin_cnt, (uint64_t)(dres.index + 1)); + *pmax_cnt = nghttp3_max(*pmax_cnt, (uint64_t)(dres.index + 1)); + *pmin_cnt = nghttp3_min(*pmin_cnt, (uint64_t)(dres.index + 1)); return nghttp3_qpack_encoder_write_dynamic_indexed_name( encoder, rbuf, (size_t)dres.index, base, nv); @@ -1616,8 +1616,8 @@ int nghttp3_qpack_encoder_encode_nv(nghttp3_qpack_encoder *encoder, } if (allow_blocking) { new_ent = nghttp3_qpack_context_dtable_top(&encoder->ctx); - *pmax_cnt = nghttp3_max_uint64(*pmax_cnt, new_ent->absidx + 1); - *pmin_cnt = nghttp3_min_uint64(*pmin_cnt, new_ent->absidx + 1); + *pmax_cnt = nghttp3_max(*pmax_cnt, new_ent->absidx + 1); + *pmin_cnt = nghttp3_min(*pmin_cnt, new_ent->absidx + 1); return nghttp3_qpack_encoder_write_dynamic_indexed(encoder, rbuf, new_ent->absidx, base); @@ -1782,8 +1782,7 @@ int nghttp3_qpack_stream_add_ref(nghttp3_qpack_stream *stream, if (nghttp3_ringbuf_full(&stream->refs)) { rv = nghttp3_ringbuf_reserve( - &stream->refs, - nghttp3_max_size(4, nghttp3_ringbuf_len(&stream->refs) * 2)); + &stream->refs, nghttp3_max(4, nghttp3_ringbuf_len(&stream->refs) * 2)); if (rv != 0) { return rv; } @@ -1815,28 +1814,26 @@ void nghttp3_qpack_stream_pop_ref(nghttp3_qpack_stream *stream) { nghttp3_ringbuf_pop_front(&stream->refs); } -int nghttp3_qpack_encoder_write_static_indexed(nghttp3_qpack_encoder *encoder, - nghttp3_buf *rbuf, - uint64_t absidx) { +int nghttp3_qpack_encoder_write_static_indexed( + const nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, uint64_t absidx) { DEBUGF("qpack::encode: Indexed Field Line (static) absidx=%" PRIu64 "\n", absidx); - return qpack_write_number(rbuf, 0xc0, absidx, 6, encoder->ctx.mem); + return qpack_write_number(rbuf, 0xC0U, absidx, 6, encoder->ctx.mem); } -int nghttp3_qpack_encoder_write_dynamic_indexed(nghttp3_qpack_encoder *encoder, - nghttp3_buf *rbuf, - uint64_t absidx, - uint64_t base) { +int nghttp3_qpack_encoder_write_dynamic_indexed( + const nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, uint64_t absidx, + uint64_t base) { DEBUGF("qpack::encode: Indexed Field Line (dynamic) absidx=%" PRIu64 " base=%" PRIu64 "\n", absidx, base); if (absidx < base) { - return qpack_write_number(rbuf, 0x80, base - absidx - 1, 6, + return qpack_write_number(rbuf, 0x80U, base - absidx - 1, 6, encoder->ctx.mem); } - return qpack_write_number(rbuf, 0x10, absidx - base, 4, encoder->ctx.mem); + return qpack_write_number(rbuf, 0x10U, absidx - base, 4, encoder->ctx.mem); } /* @@ -1851,10 +1848,10 @@ int nghttp3_qpack_encoder_write_dynamic_indexed(nghttp3_qpack_encoder *encoder, * NGHTTP3_ERR_NOMEM * Out of memory. */ -static int qpack_encoder_write_indexed_name(nghttp3_qpack_encoder *encoder, - nghttp3_buf *buf, uint8_t fb, - uint64_t nameidx, size_t prefix, - const nghttp3_nv *nv) { +static int +qpack_encoder_write_indexed_name(const nghttp3_qpack_encoder *encoder, + nghttp3_buf *buf, uint8_t fb, uint64_t nameidx, + size_t prefix, const nghttp3_nv *nv) { int rv; size_t len = nghttp3_qpack_put_varint_len(nameidx, prefix); uint8_t *p; @@ -1880,7 +1877,7 @@ static int qpack_encoder_write_indexed_name(nghttp3_qpack_encoder *encoder, p = nghttp3_qpack_put_varint(p, nameidx, prefix); if (h) { - *p = 0x80; + *p = 0x80U; p = nghttp3_qpack_put_varint(p, hlen, 7); p = nghttp3_qpack_huffman_encode(p, nv->value, nv->valuelen); } else { @@ -1899,10 +1896,11 @@ static int qpack_encoder_write_indexed_name(nghttp3_qpack_encoder *encoder, } int nghttp3_qpack_encoder_write_static_indexed_name( - nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, uint64_t absidx, + const nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, uint64_t absidx, const nghttp3_nv *nv) { uint8_t fb = - (uint8_t)(0x50 | ((nv->flags & NGHTTP3_NV_FLAG_NEVER_INDEX) ? 0x20 : 0)); + (uint8_t)(0x50U | + ((nv->flags & NGHTTP3_NV_FLAG_NEVER_INDEX) ? 0x20U : 0x00U)); DEBUGF("qpack::encode: Literal Field Line With Name Reference (static) " "absidx=%" PRIu64 " never=%d\n", @@ -1911,7 +1909,7 @@ int nghttp3_qpack_encoder_write_static_indexed_name( } int nghttp3_qpack_encoder_write_dynamic_indexed_name( - nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, uint64_t absidx, + const nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, uint64_t absidx, uint64_t base, const nghttp3_nv *nv) { uint8_t fb; @@ -1920,13 +1918,13 @@ int nghttp3_qpack_encoder_write_dynamic_indexed_name( absidx, base, (nv->flags & NGHTTP3_NV_FLAG_NEVER_INDEX) != 0); if (absidx < base) { - fb = - (uint8_t)(0x40 | ((nv->flags & NGHTTP3_NV_FLAG_NEVER_INDEX) ? 0x20 : 0)); + fb = (uint8_t)(0x40U | + ((nv->flags & NGHTTP3_NV_FLAG_NEVER_INDEX) ? 0x20U : 0x00U)); return qpack_encoder_write_indexed_name(encoder, rbuf, fb, base - absidx - 1, 4, nv); } - fb = (nv->flags & NGHTTP3_NV_FLAG_NEVER_INDEX) ? 0x08 : 0; + fb = (nv->flags & NGHTTP3_NV_FLAG_NEVER_INDEX) ? 0x08U : 0x0U; return qpack_encoder_write_indexed_name(encoder, rbuf, fb, absidx - base, 3, nv); } @@ -1943,7 +1941,7 @@ int nghttp3_qpack_encoder_write_dynamic_indexed_name( * NGHTTP3_ERR_NOMEM * Out of memory. */ -static int qpack_encoder_write_literal(nghttp3_qpack_encoder *encoder, +static int qpack_encoder_write_literal(const nghttp3_qpack_encoder *encoder, nghttp3_buf *buf, uint8_t fb, size_t prefix, const nghttp3_nv *nv) { int rv; @@ -1990,7 +1988,7 @@ static int qpack_encoder_write_literal(nghttp3_qpack_encoder *encoder, *p = 0; if (vh) { - *p |= 0x80; + *p |= 0x80U; p = nghttp3_qpack_put_varint(p, vhlen, 7); p = nghttp3_qpack_huffman_encode(p, nv->value, nv->valuelen); } else { @@ -2007,40 +2005,38 @@ static int qpack_encoder_write_literal(nghttp3_qpack_encoder *encoder, return 0; } -int nghttp3_qpack_encoder_write_literal(nghttp3_qpack_encoder *encoder, +int nghttp3_qpack_encoder_write_literal(const nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, const nghttp3_nv *nv) { uint8_t fb = - (uint8_t)(0x20 | ((nv->flags & NGHTTP3_NV_FLAG_NEVER_INDEX) ? 0x10 : 0)); + (uint8_t)(0x20U | + ((nv->flags & NGHTTP3_NV_FLAG_NEVER_INDEX) ? 0x10U : 0x0U)); DEBUGF("qpack::encode: Literal Field Line With Literal Name\n"); return qpack_encoder_write_literal(encoder, rbuf, fb, 3, nv); } -int nghttp3_qpack_encoder_write_static_insert(nghttp3_qpack_encoder *encoder, - nghttp3_buf *ebuf, - uint64_t absidx, - const nghttp3_nv *nv) { +int nghttp3_qpack_encoder_write_static_insert( + const nghttp3_qpack_encoder *encoder, nghttp3_buf *ebuf, uint64_t absidx, + const nghttp3_nv *nv) { DEBUGF("qpack::encode: Insert With Name Reference (static) absidx=%" PRIu64 "\n", absidx); - return qpack_encoder_write_indexed_name(encoder, ebuf, 0xc0, absidx, 6, nv); + return qpack_encoder_write_indexed_name(encoder, ebuf, 0xC0U, absidx, 6, nv); } -int nghttp3_qpack_encoder_write_dynamic_insert(nghttp3_qpack_encoder *encoder, - nghttp3_buf *ebuf, - uint64_t absidx, - const nghttp3_nv *nv) { +int nghttp3_qpack_encoder_write_dynamic_insert( + const nghttp3_qpack_encoder *encoder, nghttp3_buf *ebuf, uint64_t absidx, + const nghttp3_nv *nv) { DEBUGF("qpack::encode: Insert With Name Reference (dynamic) absidx=%" PRIu64 "\n", absidx); return qpack_encoder_write_indexed_name( - encoder, ebuf, 0x80, encoder->ctx.next_absidx - absidx - 1, 6, nv); + encoder, ebuf, 0x80U, encoder->ctx.next_absidx - absidx - 1, 6, nv); } -int nghttp3_qpack_encoder_write_duplicate_insert(nghttp3_qpack_encoder *encoder, - nghttp3_buf *ebuf, - uint64_t absidx) { +int nghttp3_qpack_encoder_write_duplicate_insert( + const nghttp3_qpack_encoder *encoder, nghttp3_buf *ebuf, uint64_t absidx) { uint64_t idx = encoder->ctx.next_absidx - absidx - 1; size_t len = nghttp3_qpack_put_varint_len(idx, 5); uint8_t *p; @@ -2065,11 +2061,11 @@ int nghttp3_qpack_encoder_write_duplicate_insert(nghttp3_qpack_encoder *encoder, return 0; } -int nghttp3_qpack_encoder_write_literal_insert(nghttp3_qpack_encoder *encoder, - nghttp3_buf *ebuf, - const nghttp3_nv *nv) { +int nghttp3_qpack_encoder_write_literal_insert( + const nghttp3_qpack_encoder *encoder, nghttp3_buf *ebuf, + const nghttp3_nv *nv) { DEBUGF("qpack::encode: Insert With Literal Name\n"); - return qpack_encoder_write_literal(encoder, ebuf, 0x40, 5, nv); + return qpack_encoder_write_literal(encoder, ebuf, 0x40U, 5, nv); } int nghttp3_qpack_context_dtable_add(nghttp3_qpack_context *ctx, @@ -2112,8 +2108,7 @@ int nghttp3_qpack_context_dtable_add(nghttp3_qpack_context *ctx, if (nghttp3_ringbuf_full(&ctx->dtable)) { rv = nghttp3_ringbuf_reserve( - &ctx->dtable, - nghttp3_max_size(128, nghttp3_ringbuf_len(&ctx->dtable) * 2)); + &ctx->dtable, nghttp3_max(128, nghttp3_ringbuf_len(&ctx->dtable) * 2)); if (rv != 0) { goto fail; } @@ -2418,11 +2413,16 @@ void nghttp3_qpack_encoder_cancel_stream(nghttp3_qpack_encoder *encoder, size_t nghttp3_qpack_encoder_get_num_blocked_streams(nghttp3_qpack_encoder *encoder) { + return nghttp3_qpack_encoder_get_num_blocked_streams2(encoder); +} + +size_t nghttp3_qpack_encoder_get_num_blocked_streams2( + const nghttp3_qpack_encoder *encoder) { return nghttp3_ksl_len(&encoder->blocked_streams); } int nghttp3_qpack_encoder_write_field_section_prefix( - nghttp3_qpack_encoder *encoder, nghttp3_buf *pbuf, uint64_t ricnt, + const nghttp3_qpack_encoder *encoder, nghttp3_buf *pbuf, uint64_t ricnt, uint64_t base) { size_t max_ents = encoder->ctx.hard_max_dtable_capacity / NGHTTP3_QPACK_ENTRY_OVERHEAD; @@ -2446,7 +2446,7 @@ int nghttp3_qpack_encoder_write_field_section_prefix( p = nghttp3_qpack_put_varint(p, encricnt, 8); if (sign) { - *p = 0x80; + *p = 0x80U; } else { *p = 0; } @@ -2507,7 +2507,7 @@ static nghttp3_ssize qpack_read_varint(int *fin, } for (; p != end; ++p, shift += 7) { - add = (*p) & 0x7f; + add = (*p) & 0x7FU; if (shift > 62) { return NGHTTP3_ERR_QPACK_FATAL; @@ -2568,15 +2568,15 @@ nghttp3_ssize nghttp3_qpack_encoder_read_decoder(nghttp3_qpack_encoder *encoder, for (; p != end;) { switch (encoder->state) { case NGHTTP3_QPACK_DS_STATE_OPCODE: - switch ((*p) & 0xc0) { - case 0x80: - case 0xc0: + switch ((*p) & 0xC0U) { + case 0x80U: + case 0xC0U: DEBUGF("qpack::encode: OPCODE_SECTION_ACK\n"); encoder->opcode = NGHTTP3_QPACK_DS_OPCODE_SECTION_ACK; encoder->rstate.prefix = 7; break; - case 0x40: + case 0x40U: DEBUGF("qpack::encode: OPCODE_STREAM_CANCEL\n"); encoder->opcode = NGHTTP3_QPACK_DS_OPCODE_STREAM_CANCEL; encoder->rstate.prefix = 6; @@ -2673,7 +2673,7 @@ uint8_t *nghttp3_qpack_put_varint(uint8_t *buf, uint64_t n, size_t prefix) { n -= k; for (; n >= 128; n >>= 7) { - *buf++ = (uint8_t)((1 << 7) | (n & 0x7f)); + *buf++ = (uint8_t)(0x80U | (n & 0x7FU)); } *buf++ = (uint8_t)n; @@ -2766,7 +2766,7 @@ static nghttp3_ssize qpack_read_string(nghttp3_qpack_read_state *rstate, nghttp3_buf *dest, const uint8_t *begin, const uint8_t *end) { size_t len = (size_t)(end - begin); - size_t n = (size_t)nghttp3_min_uint64((uint64_t)len, rstate->left); + size_t n = (size_t)nghttp3_min((uint64_t)len, rstate->left); dest->last = nghttp3_cpymem(dest->last, begin, n); @@ -2783,8 +2783,9 @@ static nghttp3_ssize qpack_read_string(nghttp3_qpack_read_state *rstate, * NGHTTP3_ERR_QPACK_FATAL * rstate->absidx is invalid. */ -static int qpack_decoder_validate_index(nghttp3_qpack_decoder *decoder, - nghttp3_qpack_read_state *rstate) { +static int +qpack_decoder_validate_index(const nghttp3_qpack_decoder *decoder, + const nghttp3_qpack_read_state *rstate) { if (rstate->dynamic) { return rstate->absidx < decoder->ctx.next_absidx && decoder->ctx.next_absidx - rstate->absidx - 1 < @@ -2840,20 +2841,20 @@ nghttp3_ssize nghttp3_qpack_decoder_read_encoder(nghttp3_qpack_decoder *decoder, busy = 0; switch (decoder->state) { case NGHTTP3_QPACK_ES_STATE_OPCODE: - switch ((*p) & 0xe0) { - case 0x80: - case 0xa0: - case 0xc0: - case 0xe0: + switch ((*p) & 0xE0U) { + case 0x80U: + case 0xA0U: + case 0xC0U: + case 0xE0U: DEBUGF("qpack::decode: OPCODE_INSERT_INDEXED\n"); decoder->opcode = NGHTTP3_QPACK_ES_OPCODE_INSERT_INDEXED; - decoder->rstate.dynamic = !((*p) & 0x40); + decoder->rstate.dynamic = !((*p) & 0x40U); decoder->rstate.prefix = 6; decoder->state = NGHTTP3_QPACK_ES_STATE_READ_INDEX; break; - case 0x40: - case 0x60: + case 0x40U: + case 0x60U: DEBUGF("qpack::decode: OPCODE_INSERT\n"); decoder->opcode = NGHTTP3_QPACK_ES_OPCODE_INSERT; decoder->rstate.dynamic = 0; @@ -2861,7 +2862,7 @@ nghttp3_ssize nghttp3_qpack_decoder_read_encoder(nghttp3_qpack_decoder *decoder, decoder->state = NGHTTP3_QPACK_ES_STATE_CHECK_NAME_HUFFMAN; break; - case 0x20: + case 0x20U: DEBUGF("qpack::decode: OPCODE_SET_DTABLE_TABLE_CAP\n"); decoder->opcode = NGHTTP3_QPACK_ES_OPCODE_SET_DTABLE_CAP; decoder->rstate.prefix = 5; @@ -2960,7 +2961,10 @@ nghttp3_ssize nghttp3_qpack_decoder_read_encoder(nghttp3_qpack_decoder *decoder, decoder->state = NGHTTP3_QPACK_ES_STATE_READ_NAME_HUFFMAN; nghttp3_qpack_huffman_decode_context_init(&decoder->rstate.huffman_ctx); rv = nghttp3_rcbuf_new(&decoder->rstate.name, - (size_t)decoder->rstate.left * 2 + 1, mem); + nghttp3_qpack_huffman_estimate_decode_length( + (size_t)decoder->rstate.left) + + 1, + mem); } else { decoder->state = NGHTTP3_QPACK_ES_STATE_READ_NAME; rv = nghttp3_rcbuf_new(&decoder->rstate.name, @@ -3042,7 +3046,10 @@ nghttp3_ssize nghttp3_qpack_decoder_read_encoder(nghttp3_qpack_decoder *decoder, decoder->state = NGHTTP3_QPACK_ES_STATE_READ_VALUE_HUFFMAN; nghttp3_qpack_huffman_decode_context_init(&decoder->rstate.huffman_ctx); rv = nghttp3_rcbuf_new(&decoder->rstate.value, - (size_t)decoder->rstate.left * 2 + 1, mem); + nghttp3_qpack_huffman_estimate_decode_length( + (size_t)decoder->rstate.left) + + 1, + mem); } else { decoder->state = NGHTTP3_QPACK_ES_STATE_READ_VALUE; rv = nghttp3_rcbuf_new(&decoder->rstate.value, @@ -3288,7 +3295,7 @@ int nghttp3_qpack_decoder_dtable_literal_add(nghttp3_qpack_decoder *decoder) { void nghttp3_qpack_decoder_set_max_concurrent_streams( nghttp3_qpack_decoder *decoder, size_t max_concurrent_streams) { decoder->max_concurrent_streams = - nghttp3_max_size(decoder->max_concurrent_streams, max_concurrent_streams); + nghttp3_max(decoder->max_concurrent_streams, max_concurrent_streams); } void nghttp3_qpack_stream_context_init(nghttp3_qpack_stream_context *sctx, @@ -3316,6 +3323,11 @@ void nghttp3_qpack_stream_context_reset(nghttp3_qpack_stream_context *sctx) { uint64_t nghttp3_qpack_stream_context_get_ricnt(nghttp3_qpack_stream_context *sctx) { + return nghttp3_qpack_stream_context_get_ricnt2(sctx); +} + +uint64_t nghttp3_qpack_stream_context_get_ricnt2( + const nghttp3_qpack_stream_context *sctx) { return sctx->ricnt; } @@ -3363,7 +3375,7 @@ nghttp3_qpack_decoder_read_request(nghttp3_qpack_decoder *decoder, sctx->state = NGHTTP3_QPACK_RS_STATE_DBASE_SIGN; break; case NGHTTP3_QPACK_RS_STATE_DBASE_SIGN: - if ((*p) & 0x80) { + if ((*p) & 0x80U) { sctx->dbase_sign = 1; } sctx->state = NGHTTP3_QPACK_RS_STATE_DBASE; @@ -3413,45 +3425,45 @@ nghttp3_qpack_decoder_read_request(nghttp3_qpack_decoder *decoder, case NGHTTP3_QPACK_RS_STATE_OPCODE: assert(sctx->rstate.left == 0); assert(sctx->rstate.shift == 0); - switch ((*p) & 0xf0) { - case 0x80: - case 0x90: - case 0xa0: - case 0xb0: - case 0xc0: - case 0xd0: - case 0xe0: - case 0xf0: + switch ((*p) & 0xF0U) { + case 0x80U: + case 0x90U: + case 0xA0U: + case 0xB0U: + case 0xC0U: + case 0xD0U: + case 0xE0U: + case 0xF0U: DEBUGF("qpack::decode: OPCODE_INDEXED\n"); sctx->opcode = NGHTTP3_QPACK_RS_OPCODE_INDEXED; - sctx->rstate.dynamic = !((*p) & 0x40); + sctx->rstate.dynamic = !((*p) & 0x40U); sctx->rstate.prefix = 6; sctx->state = NGHTTP3_QPACK_RS_STATE_READ_INDEX; break; - case 0x40: - case 0x50: - case 0x60: - case 0x70: + case 0x40U: + case 0x50U: + case 0x60U: + case 0x70U: DEBUGF("qpack::decode: OPCODE_INDEXED_NAME\n"); sctx->opcode = NGHTTP3_QPACK_RS_OPCODE_INDEXED_NAME; - sctx->rstate.never = (*p) & 0x20; - sctx->rstate.dynamic = !((*p) & 0x10); + sctx->rstate.never = (*p) & 0x20U; + sctx->rstate.dynamic = !((*p) & 0x10U); sctx->rstate.prefix = 4; sctx->state = NGHTTP3_QPACK_RS_STATE_READ_INDEX; break; - case 0x20: - case 0x30: + case 0x20U: + case 0x30U: DEBUGF("qpack::decode: OPCODE_LITERAL\n"); sctx->opcode = NGHTTP3_QPACK_RS_OPCODE_LITERAL; - sctx->rstate.never = (*p) & 0x10; + sctx->rstate.never = (*p) & 0x10U; sctx->rstate.dynamic = 0; sctx->rstate.prefix = 3; sctx->state = NGHTTP3_QPACK_RS_STATE_CHECK_NAME_HUFFMAN; break; - case 0x10: + case 0x10U: DEBUGF("qpack::decode: OPCODE_INDEXED_PB\n"); sctx->opcode = NGHTTP3_QPACK_RS_OPCODE_INDEXED_PB; sctx->rstate.dynamic = 1; @@ -3462,7 +3474,7 @@ nghttp3_qpack_decoder_read_request(nghttp3_qpack_decoder *decoder, default: DEBUGF("qpack::decode: OPCODE_INDEXED_NAME_PB\n"); sctx->opcode = NGHTTP3_QPACK_RS_OPCODE_INDEXED_NAME_PB; - sctx->rstate.never = (*p) & 0x08; + sctx->rstate.never = (*p) & 0x08U; sctx->rstate.dynamic = 1; sctx->rstate.prefix = 3; sctx->state = NGHTTP3_QPACK_RS_STATE_READ_INDEX; @@ -3556,7 +3568,10 @@ nghttp3_qpack_decoder_read_request(nghttp3_qpack_decoder *decoder, sctx->state = NGHTTP3_QPACK_RS_STATE_READ_NAME_HUFFMAN; nghttp3_qpack_huffman_decode_context_init(&sctx->rstate.huffman_ctx); rv = nghttp3_rcbuf_new(&sctx->rstate.name, - (size_t)sctx->rstate.left * 2 + 1, mem); + nghttp3_qpack_huffman_estimate_decode_length( + (size_t)sctx->rstate.left) + + 1, + mem); } else { sctx->state = NGHTTP3_QPACK_RS_STATE_READ_NAME; rv = nghttp3_rcbuf_new(&sctx->rstate.name, @@ -3636,7 +3651,10 @@ nghttp3_qpack_decoder_read_request(nghttp3_qpack_decoder *decoder, sctx->state = NGHTTP3_QPACK_RS_STATE_READ_VALUE_HUFFMAN; nghttp3_qpack_huffman_decode_context_init(&sctx->rstate.huffman_ctx); rv = nghttp3_rcbuf_new(&sctx->rstate.value, - (size_t)sctx->rstate.left * 2 + 1, mem); + nghttp3_qpack_huffman_estimate_decode_length( + (size_t)sctx->rstate.left) + + 1, + mem); } else { sctx->state = NGHTTP3_QPACK_RS_STATE_READ_VALUE; rv = nghttp3_rcbuf_new(&sctx->rstate.value, @@ -3766,8 +3784,8 @@ nghttp3_qpack_decoder_read_request(nghttp3_qpack_decoder *decoder, return rv; } -static int qpack_decoder_dbuf_overflow(nghttp3_qpack_decoder *decoder) { - size_t limit = nghttp3_max_size(decoder->max_concurrent_streams, 100); +static int qpack_decoder_dbuf_overflow(const nghttp3_qpack_decoder *decoder) { + size_t limit = nghttp3_max(decoder->max_concurrent_streams, 100); /* 10 = nghttp3_qpack_put_varint_len((1ULL << 62) - 1, 2)) */ return nghttp3_buf_len(&decoder->dbuf) > limit * 2 * 10; } @@ -3790,7 +3808,7 @@ int nghttp3_qpack_decoder_write_section_ack( } p = dbuf->last; - *p = 0x80; + *p = 0x80U; dbuf->last = nghttp3_qpack_put_varint(p, (uint64_t)sctx->stream_id, 7); if (decoder->written_icnt < sctx->ricnt) { @@ -3802,6 +3820,11 @@ int nghttp3_qpack_decoder_write_section_ack( size_t nghttp3_qpack_decoder_get_decoder_streamlen(nghttp3_qpack_decoder *decoder) { + return nghttp3_qpack_decoder_get_decoder_streamlen2(decoder); +} + +size_t nghttp3_qpack_decoder_get_decoder_streamlen2( + const nghttp3_qpack_decoder *decoder) { uint64_t n; size_t len = 0; @@ -3863,14 +3886,14 @@ int nghttp3_qpack_decoder_cancel_stream(nghttp3_qpack_decoder *decoder, } p = decoder->dbuf.last; - *p = 0x40; + *p = 0x40U; decoder->dbuf.last = nghttp3_qpack_put_varint(p, (uint64_t)stream_id, 6); return 0; } -int nghttp3_qpack_decoder_reconstruct_ricnt(nghttp3_qpack_decoder *decoder, - uint64_t *dest, uint64_t encricnt) { +int nghttp3_qpack_decoder_reconstruct_ricnt( + const nghttp3_qpack_decoder *decoder, uint64_t *dest, uint64_t encricnt) { uint64_t max_ents, full, max, max_wrapped, ricnt; if (encricnt == 0) { @@ -3906,7 +3929,7 @@ int nghttp3_qpack_decoder_reconstruct_ricnt(nghttp3_qpack_decoder *decoder, return 0; } -int nghttp3_qpack_decoder_rel2abs(nghttp3_qpack_decoder *decoder, +int nghttp3_qpack_decoder_rel2abs(const nghttp3_qpack_decoder *decoder, nghttp3_qpack_read_state *rstate) { DEBUGF("qpack::decode: dynamic=%d relidx=%" PRIu64 " icnt=%" PRIu64 "\n", rstate->dynamic, rstate->left, decoder->ctx.next_absidx); @@ -3925,7 +3948,7 @@ int nghttp3_qpack_decoder_rel2abs(nghttp3_qpack_decoder *decoder, return 0; } -int nghttp3_qpack_decoder_brel2abs(nghttp3_qpack_decoder *decoder, +int nghttp3_qpack_decoder_brel2abs(const nghttp3_qpack_decoder *decoder, nghttp3_qpack_stream_context *sctx) { nghttp3_qpack_read_state *rstate = &sctx->rstate; @@ -3952,7 +3975,7 @@ int nghttp3_qpack_decoder_brel2abs(nghttp3_qpack_decoder *decoder, return 0; } -int nghttp3_qpack_decoder_pbrel2abs(nghttp3_qpack_decoder *decoder, +int nghttp3_qpack_decoder_pbrel2abs(const nghttp3_qpack_decoder *decoder, nghttp3_qpack_stream_context *sctx) { nghttp3_qpack_read_state *rstate = &sctx->rstate; @@ -3974,8 +3997,8 @@ int nghttp3_qpack_decoder_pbrel2abs(nghttp3_qpack_decoder *decoder, } static void -qpack_decoder_emit_static_indexed(nghttp3_qpack_decoder *decoder, - nghttp3_qpack_stream_context *sctx, +qpack_decoder_emit_static_indexed(const nghttp3_qpack_decoder *decoder, + const nghttp3_qpack_stream_context *sctx, nghttp3_qpack_nv *nv) { const nghttp3_qpack_static_header *shd = &stable[sctx->rstate.absidx]; (void)decoder; @@ -3988,7 +4011,7 @@ qpack_decoder_emit_static_indexed(nghttp3_qpack_decoder *decoder, static void qpack_decoder_emit_dynamic_indexed(nghttp3_qpack_decoder *decoder, - nghttp3_qpack_stream_context *sctx, + const nghttp3_qpack_stream_context *sctx, nghttp3_qpack_nv *nv) { nghttp3_qpack_entry *ent = nghttp3_qpack_context_dtable_get(&decoder->ctx, sctx->rstate.absidx); @@ -3999,9 +4022,9 @@ qpack_decoder_emit_dynamic_indexed(nghttp3_qpack_decoder *decoder, nghttp3_rcbuf_incref(nv->value); } -void nghttp3_qpack_decoder_emit_indexed(nghttp3_qpack_decoder *decoder, - nghttp3_qpack_stream_context *sctx, - nghttp3_qpack_nv *nv) { +void nghttp3_qpack_decoder_emit_indexed( + nghttp3_qpack_decoder *decoder, const nghttp3_qpack_stream_context *sctx, + nghttp3_qpack_nv *nv) { DEBUGF("qpack::decode: Indexed (%s) absidx=%" PRIu64 "\n", sctx->rstate.dynamic ? "dynamic" : "static", sctx->rstate.absidx); @@ -4013,7 +4036,7 @@ void nghttp3_qpack_decoder_emit_indexed(nghttp3_qpack_decoder *decoder, } static void -qpack_decoder_emit_static_indexed_name(nghttp3_qpack_decoder *decoder, +qpack_decoder_emit_static_indexed_name(const nghttp3_qpack_decoder *decoder, nghttp3_qpack_stream_context *sctx, nghttp3_qpack_nv *nv) { const nghttp3_qpack_static_header *shd = &stable[sctx->rstate.absidx]; @@ -4073,7 +4096,7 @@ int nghttp3_qpack_decoder_emit_indexed_name(nghttp3_qpack_decoder *decoder, return 0; } -void nghttp3_qpack_decoder_emit_literal(nghttp3_qpack_decoder *decoder, +void nghttp3_qpack_decoder_emit_literal(const nghttp3_qpack_decoder *decoder, nghttp3_qpack_stream_context *sctx, nghttp3_qpack_nv *nv) { (void)decoder; diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_qpack.h b/deps/ngtcp2/nghttp3/lib/nghttp3_qpack.h index 1c13849a8aa55a..2b8dca9d5cf746 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_qpack.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_qpack.h @@ -40,7 +40,7 @@ #include "nghttp3_ksl.h" #include "nghttp3_qpack_huffman.h" -#define NGHTTP3_QPACK_INT_MAX ((1ull << 62) - 1) +#define NGHTTP3_QPACK_INT_MAX ((1ULL << 62) - 1) /* NGHTTP3_QPACK_MAX_NAMELEN is the maximum (compressed) length of header name this library can decode. */ @@ -223,10 +223,10 @@ typedef enum nghttp3_qpack_decoder_stream_opcode { /* QPACK encoder flags */ /* NGHTTP3_QPACK_ENCODER_FLAG_NONE indicates that no flag is set. */ -#define NGHTTP3_QPACK_ENCODER_FLAG_NONE 0x00u +#define NGHTTP3_QPACK_ENCODER_FLAG_NONE 0x00U /* NGHTTP3_QPACK_ENCODER_FLAG_PENDING_SET_DTABLE_CAP indicates that Set Dynamic Table Capacity is required. */ -#define NGHTTP3_QPACK_ENCODER_FLAG_PENDING_SET_DTABLE_CAP 0x01u +#define NGHTTP3_QPACK_ENCODER_FLAG_PENDING_SET_DTABLE_CAP 0x01U struct nghttp3_qpack_encoder { nghttp3_qpack_context ctx; @@ -350,7 +350,7 @@ nghttp3_qpack_lookup_result nghttp3_qpack_encoder_lookup_dtable( * Out of memory. */ int nghttp3_qpack_encoder_write_field_section_prefix( - nghttp3_qpack_encoder *encoder, nghttp3_buf *pbuf, uint64_t ricnt, + const nghttp3_qpack_encoder *encoder, nghttp3_buf *pbuf, uint64_t ricnt, uint64_t base); /* @@ -363,9 +363,8 @@ int nghttp3_qpack_encoder_write_field_section_prefix( * NGHTTP3_ERR_NOMEM * Out of memory. */ -int nghttp3_qpack_encoder_write_static_indexed(nghttp3_qpack_encoder *encoder, - nghttp3_buf *rbuf, - uint64_t absidx); +int nghttp3_qpack_encoder_write_static_indexed( + const nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, uint64_t absidx); /* * nghttp3_qpack_encoder_write_dynamic_indexed writes Indexed Header @@ -378,9 +377,9 @@ int nghttp3_qpack_encoder_write_static_indexed(nghttp3_qpack_encoder *encoder, * NGHTTP3_ERR_NOMEM * Out of memory. */ -int nghttp3_qpack_encoder_write_dynamic_indexed(nghttp3_qpack_encoder *encoder, - nghttp3_buf *rbuf, - uint64_t absidx, uint64_t base); +int nghttp3_qpack_encoder_write_dynamic_indexed( + const nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, uint64_t absidx, + uint64_t base); /* * nghttp3_qpack_encoder_write_static_indexed writes Literal Header @@ -395,7 +394,7 @@ int nghttp3_qpack_encoder_write_dynamic_indexed(nghttp3_qpack_encoder *encoder, * Out of memory. */ int nghttp3_qpack_encoder_write_static_indexed_name( - nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, uint64_t absidx, + const nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, uint64_t absidx, const nghttp3_nv *nv); /* @@ -411,7 +410,7 @@ int nghttp3_qpack_encoder_write_static_indexed_name( * Out of memory. */ int nghttp3_qpack_encoder_write_dynamic_indexed_name( - nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, uint64_t absidx, + const nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, uint64_t absidx, uint64_t base, const nghttp3_nv *nv); /* @@ -424,7 +423,7 @@ int nghttp3_qpack_encoder_write_dynamic_indexed_name( * NGHTTP3_ERR_NOMEM * Out of memory. */ -int nghttp3_qpack_encoder_write_literal(nghttp3_qpack_encoder *encoder, +int nghttp3_qpack_encoder_write_literal(const nghttp3_qpack_encoder *encoder, nghttp3_buf *rbuf, const nghttp3_nv *nv); @@ -439,10 +438,9 @@ int nghttp3_qpack_encoder_write_literal(nghttp3_qpack_encoder *encoder, * NGHTTP3_ERR_NOMEM * Out of memory. */ -int nghttp3_qpack_encoder_write_static_insert(nghttp3_qpack_encoder *encoder, - nghttp3_buf *ebuf, - uint64_t absidx, - const nghttp3_nv *nv); +int nghttp3_qpack_encoder_write_static_insert( + const nghttp3_qpack_encoder *encoder, nghttp3_buf *ebuf, uint64_t absidx, + const nghttp3_nv *nv); /* * nghttp3_qpack_encoder_write_dynamic_insert writes Insert With Name @@ -455,10 +453,9 @@ int nghttp3_qpack_encoder_write_static_insert(nghttp3_qpack_encoder *encoder, * NGHTTP3_ERR_NOMEM * Out of memory. */ -int nghttp3_qpack_encoder_write_dynamic_insert(nghttp3_qpack_encoder *encoder, - nghttp3_buf *ebuf, - uint64_t absidx, - const nghttp3_nv *nv); +int nghttp3_qpack_encoder_write_dynamic_insert( + const nghttp3_qpack_encoder *encoder, nghttp3_buf *ebuf, uint64_t absidx, + const nghttp3_nv *nv); /* * nghttp3_qpack_encoder_write_duplicate_insert writes Duplicate to @@ -471,9 +468,8 @@ int nghttp3_qpack_encoder_write_dynamic_insert(nghttp3_qpack_encoder *encoder, * NGHTTP3_ERR_NOMEM * Out of memory. */ -int nghttp3_qpack_encoder_write_duplicate_insert(nghttp3_qpack_encoder *encoder, - nghttp3_buf *ebuf, - uint64_t absidx); +int nghttp3_qpack_encoder_write_duplicate_insert( + const nghttp3_qpack_encoder *encoder, nghttp3_buf *ebuf, uint64_t absidx); /* * nghttp3_qpack_encoder_write_literal_insert writes Insert With @@ -485,12 +481,12 @@ int nghttp3_qpack_encoder_write_duplicate_insert(nghttp3_qpack_encoder *encoder, * NGHTTP3_ERR_NOMEM * Out of memory. */ -int nghttp3_qpack_encoder_write_literal_insert(nghttp3_qpack_encoder *encoder, - nghttp3_buf *ebuf, - const nghttp3_nv *nv); +int nghttp3_qpack_encoder_write_literal_insert( + const nghttp3_qpack_encoder *encoder, nghttp3_buf *ebuf, + const nghttp3_nv *nv); -int nghttp3_qpack_encoder_stream_is_blocked(nghttp3_qpack_encoder *encoder, - nghttp3_qpack_stream *stream); +int nghttp3_qpack_encoder_stream_is_blocked( + const nghttp3_qpack_encoder *encoder, const nghttp3_qpack_stream *stream); /* * nghttp3_qpack_encoder_block_stream blocks |stream|. @@ -523,10 +519,11 @@ void nghttp3_qpack_encoder_unblock(nghttp3_qpack_encoder *encoder, * stream. */ nghttp3_qpack_stream * -nghttp3_qpack_encoder_find_stream(nghttp3_qpack_encoder *encoder, +nghttp3_qpack_encoder_find_stream(const nghttp3_qpack_encoder *encoder, int64_t stream_id); -uint64_t nghttp3_qpack_encoder_get_min_cnt(nghttp3_qpack_encoder *encoder); +uint64_t +nghttp3_qpack_encoder_get_min_cnt(const nghttp3_qpack_encoder *encoder); /* * nghttp3_qpack_encoder_shrink_dtable shrinks dynamic table so that @@ -927,8 +924,8 @@ void nghttp3_qpack_stream_context_free(nghttp3_qpack_stream_context *sctx); * NGHTTP3_ERR_QPACK_DECOMPRESSION_FAILED * Unable to reconstruct Required Insert Count. */ -int nghttp3_qpack_decoder_reconstruct_ricnt(nghttp3_qpack_decoder *decoder, - uint64_t *dest, uint64_t encricnt); +int nghttp3_qpack_decoder_reconstruct_ricnt( + const nghttp3_qpack_decoder *decoder, uint64_t *dest, uint64_t encricnt); /* * nghttp3_qpack_decoder_rel2abs converts relative index rstate->left @@ -941,7 +938,7 @@ int nghttp3_qpack_decoder_reconstruct_ricnt(nghttp3_qpack_decoder *decoder, * NGHTTP3_ERR_QPACK_ENCODER_STREAM * Relative index is invalid. */ -int nghttp3_qpack_decoder_rel2abs(nghttp3_qpack_decoder *decoder, +int nghttp3_qpack_decoder_rel2abs(const nghttp3_qpack_decoder *decoder, nghttp3_qpack_read_state *rstate); /* @@ -955,7 +952,7 @@ int nghttp3_qpack_decoder_rel2abs(nghttp3_qpack_decoder *decoder, * NGHTTP3_ERR_QPACK_DECOMPRESSION_FAILED * Base relative index is invalid. */ -int nghttp3_qpack_decoder_brel2abs(nghttp3_qpack_decoder *decoder, +int nghttp3_qpack_decoder_brel2abs(const nghttp3_qpack_decoder *decoder, nghttp3_qpack_stream_context *sctx); /* @@ -969,18 +966,18 @@ int nghttp3_qpack_decoder_brel2abs(nghttp3_qpack_decoder *decoder, * NGHTTP3_ERR_QPACK_DECOMPRESSION_FAILED * Post-Base relative index is invalid. */ -int nghttp3_qpack_decoder_pbrel2abs(nghttp3_qpack_decoder *decoder, +int nghttp3_qpack_decoder_pbrel2abs(const nghttp3_qpack_decoder *decoder, nghttp3_qpack_stream_context *sctx); -void nghttp3_qpack_decoder_emit_indexed(nghttp3_qpack_decoder *decoder, - nghttp3_qpack_stream_context *sctx, - nghttp3_qpack_nv *nv); +void nghttp3_qpack_decoder_emit_indexed( + nghttp3_qpack_decoder *decoder, const nghttp3_qpack_stream_context *sctx, + nghttp3_qpack_nv *nv); int nghttp3_qpack_decoder_emit_indexed_name(nghttp3_qpack_decoder *decoder, nghttp3_qpack_stream_context *sctx, nghttp3_qpack_nv *nv); -void nghttp3_qpack_decoder_emit_literal(nghttp3_qpack_decoder *decoder, +void nghttp3_qpack_decoder_emit_literal(const nghttp3_qpack_decoder *decoder, nghttp3_qpack_stream_context *sctx, nghttp3_qpack_nv *nv); diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman.c b/deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman.c index 8b9b6a451b6015..b784ca9970c0b4 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman.c @@ -107,7 +107,7 @@ nghttp3_qpack_huffman_decode(nghttp3_qpack_huffman_decode_context *ctx, *p++ = t.sym; } - t = qpack_huffman_decode_table[t.fstate][c & 0xf]; + t = qpack_huffman_decode_table[t.fstate][c & 0xFU]; if (t.flags & NGHTTP3_QPACK_HUFFMAN_SYM) { *p++ = t.sym; } @@ -124,6 +124,6 @@ nghttp3_qpack_huffman_decode(nghttp3_qpack_huffman_decode_context *ctx, } int nghttp3_qpack_huffman_decode_failure_state( - nghttp3_qpack_huffman_decode_context *ctx) { - return ctx->fstate == 0x100; + const nghttp3_qpack_huffman_decode_context *ctx) { + return ctx->fstate == 0x100U; } diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman.h b/deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman.h index aa262179521165..2fce4de6f011ec 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman.h @@ -105,6 +105,14 @@ nghttp3_qpack_huffman_decode(nghttp3_qpack_huffman_decode_context *ctx, * indicates that huffman decoding context is in failure state. */ int nghttp3_qpack_huffman_decode_failure_state( - nghttp3_qpack_huffman_decode_context *ctx); + const nghttp3_qpack_huffman_decode_context *ctx); + +/* + * nghttp3_qpack_huffman_estimate_decode_length returns the estimated + * decoded length of the huffman encoded string of length |len|. + */ +static inline size_t nghttp3_qpack_huffman_estimate_decode_length(size_t len) { + return len * 8 / 5; +} #endif /* !defined(NGHTTP3_QPACK_HUFFMAN_H) */ diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman_data.c b/deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman_data.c index 9eae37eb3ea1f8..ffe8fcafadb667 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman_data.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman_data.c @@ -28,71 +28,71 @@ /* Generated by mkhufftbl.py */ const nghttp3_qpack_huffman_sym huffman_sym_table[] = { - {13, 0xffc00000u}, {23, 0xffffb000u}, {28, 0xfffffe20u}, {28, 0xfffffe30u}, - {28, 0xfffffe40u}, {28, 0xfffffe50u}, {28, 0xfffffe60u}, {28, 0xfffffe70u}, - {28, 0xfffffe80u}, {24, 0xffffea00u}, {30, 0xfffffff0u}, {28, 0xfffffe90u}, - {28, 0xfffffea0u}, {30, 0xfffffff4u}, {28, 0xfffffeb0u}, {28, 0xfffffec0u}, - {28, 0xfffffed0u}, {28, 0xfffffee0u}, {28, 0xfffffef0u}, {28, 0xffffff00u}, - {28, 0xffffff10u}, {28, 0xffffff20u}, {30, 0xfffffff8u}, {28, 0xffffff30u}, - {28, 0xffffff40u}, {28, 0xffffff50u}, {28, 0xffffff60u}, {28, 0xffffff70u}, - {28, 0xffffff80u}, {28, 0xffffff90u}, {28, 0xffffffa0u}, {28, 0xffffffb0u}, - {6, 0x50000000u}, {10, 0xfe000000u}, {10, 0xfe400000u}, {12, 0xffa00000u}, - {13, 0xffc80000u}, {6, 0x54000000u}, {8, 0xf8000000u}, {11, 0xff400000u}, - {10, 0xfe800000u}, {10, 0xfec00000u}, {8, 0xf9000000u}, {11, 0xff600000u}, - {8, 0xfa000000u}, {6, 0x58000000u}, {6, 0x5c000000u}, {6, 0x60000000u}, - {5, 0x0u}, {5, 0x8000000u}, {5, 0x10000000u}, {6, 0x64000000u}, - {6, 0x68000000u}, {6, 0x6c000000u}, {6, 0x70000000u}, {6, 0x74000000u}, - {6, 0x78000000u}, {6, 0x7c000000u}, {7, 0xb8000000u}, {8, 0xfb000000u}, - {15, 0xfff80000u}, {6, 0x80000000u}, {12, 0xffb00000u}, {10, 0xff000000u}, - {13, 0xffd00000u}, {6, 0x84000000u}, {7, 0xba000000u}, {7, 0xbc000000u}, - {7, 0xbe000000u}, {7, 0xc0000000u}, {7, 0xc2000000u}, {7, 0xc4000000u}, - {7, 0xc6000000u}, {7, 0xc8000000u}, {7, 0xca000000u}, {7, 0xcc000000u}, - {7, 0xce000000u}, {7, 0xd0000000u}, {7, 0xd2000000u}, {7, 0xd4000000u}, - {7, 0xd6000000u}, {7, 0xd8000000u}, {7, 0xda000000u}, {7, 0xdc000000u}, - {7, 0xde000000u}, {7, 0xe0000000u}, {7, 0xe2000000u}, {7, 0xe4000000u}, - {8, 0xfc000000u}, {7, 0xe6000000u}, {8, 0xfd000000u}, {13, 0xffd80000u}, - {19, 0xfffe0000u}, {13, 0xffe00000u}, {14, 0xfff00000u}, {6, 0x88000000u}, - {15, 0xfffa0000u}, {5, 0x18000000u}, {6, 0x8c000000u}, {5, 0x20000000u}, - {6, 0x90000000u}, {5, 0x28000000u}, {6, 0x94000000u}, {6, 0x98000000u}, - {6, 0x9c000000u}, {5, 0x30000000u}, {7, 0xe8000000u}, {7, 0xea000000u}, - {6, 0xa0000000u}, {6, 0xa4000000u}, {6, 0xa8000000u}, {5, 0x38000000u}, - {6, 0xac000000u}, {7, 0xec000000u}, {6, 0xb0000000u}, {5, 0x40000000u}, - {5, 0x48000000u}, {6, 0xb4000000u}, {7, 0xee000000u}, {7, 0xf0000000u}, - {7, 0xf2000000u}, {7, 0xf4000000u}, {7, 0xf6000000u}, {15, 0xfffc0000u}, - {11, 0xff800000u}, {14, 0xfff40000u}, {13, 0xffe80000u}, {28, 0xffffffc0u}, - {20, 0xfffe6000u}, {22, 0xffff4800u}, {20, 0xfffe7000u}, {20, 0xfffe8000u}, - {22, 0xffff4c00u}, {22, 0xffff5000u}, {22, 0xffff5400u}, {23, 0xffffb200u}, - {22, 0xffff5800u}, {23, 0xffffb400u}, {23, 0xffffb600u}, {23, 0xffffb800u}, - {23, 0xffffba00u}, {23, 0xffffbc00u}, {24, 0xffffeb00u}, {23, 0xffffbe00u}, - {24, 0xffffec00u}, {24, 0xffffed00u}, {22, 0xffff5c00u}, {23, 0xffffc000u}, - {24, 0xffffee00u}, {23, 0xffffc200u}, {23, 0xffffc400u}, {23, 0xffffc600u}, - {23, 0xffffc800u}, {21, 0xfffee000u}, {22, 0xffff6000u}, {23, 0xffffca00u}, - {22, 0xffff6400u}, {23, 0xffffcc00u}, {23, 0xffffce00u}, {24, 0xffffef00u}, - {22, 0xffff6800u}, {21, 0xfffee800u}, {20, 0xfffe9000u}, {22, 0xffff6c00u}, - {22, 0xffff7000u}, {23, 0xffffd000u}, {23, 0xffffd200u}, {21, 0xfffef000u}, - {23, 0xffffd400u}, {22, 0xffff7400u}, {22, 0xffff7800u}, {24, 0xfffff000u}, - {21, 0xfffef800u}, {22, 0xffff7c00u}, {23, 0xffffd600u}, {23, 0xffffd800u}, - {21, 0xffff0000u}, {21, 0xffff0800u}, {22, 0xffff8000u}, {21, 0xffff1000u}, - {23, 0xffffda00u}, {22, 0xffff8400u}, {23, 0xffffdc00u}, {23, 0xffffde00u}, - {20, 0xfffea000u}, {22, 0xffff8800u}, {22, 0xffff8c00u}, {22, 0xffff9000u}, - {23, 0xffffe000u}, {22, 0xffff9400u}, {22, 0xffff9800u}, {23, 0xffffe200u}, - {26, 0xfffff800u}, {26, 0xfffff840u}, {20, 0xfffeb000u}, {19, 0xfffe2000u}, - {22, 0xffff9c00u}, {23, 0xffffe400u}, {22, 0xffffa000u}, {25, 0xfffff600u}, - {26, 0xfffff880u}, {26, 0xfffff8c0u}, {26, 0xfffff900u}, {27, 0xfffffbc0u}, - {27, 0xfffffbe0u}, {26, 0xfffff940u}, {24, 0xfffff100u}, {25, 0xfffff680u}, - {19, 0xfffe4000u}, {21, 0xffff1800u}, {26, 0xfffff980u}, {27, 0xfffffc00u}, - {27, 0xfffffc20u}, {26, 0xfffff9c0u}, {27, 0xfffffc40u}, {24, 0xfffff200u}, - {21, 0xffff2000u}, {21, 0xffff2800u}, {26, 0xfffffa00u}, {26, 0xfffffa40u}, - {28, 0xffffffd0u}, {27, 0xfffffc60u}, {27, 0xfffffc80u}, {27, 0xfffffca0u}, - {20, 0xfffec000u}, {24, 0xfffff300u}, {20, 0xfffed000u}, {21, 0xffff3000u}, - {22, 0xffffa400u}, {21, 0xffff3800u}, {21, 0xffff4000u}, {23, 0xffffe600u}, - {22, 0xffffa800u}, {22, 0xffffac00u}, {25, 0xfffff700u}, {25, 0xfffff780u}, - {24, 0xfffff400u}, {24, 0xfffff500u}, {26, 0xfffffa80u}, {23, 0xffffe800u}, - {26, 0xfffffac0u}, {27, 0xfffffcc0u}, {26, 0xfffffb00u}, {26, 0xfffffb40u}, - {27, 0xfffffce0u}, {27, 0xfffffd00u}, {27, 0xfffffd20u}, {27, 0xfffffd40u}, - {27, 0xfffffd60u}, {28, 0xffffffe0u}, {27, 0xfffffd80u}, {27, 0xfffffda0u}, - {27, 0xfffffdc0u}, {27, 0xfffffde0u}, {27, 0xfffffe00u}, {26, 0xfffffb80u}, - {30, 0xfffffffcu}}; + {13, 0xFFC00000U}, {23, 0xFFFFB000U}, {28, 0xFFFFFE20U}, {28, 0xFFFFFE30U}, + {28, 0xFFFFFE40U}, {28, 0xFFFFFE50U}, {28, 0xFFFFFE60U}, {28, 0xFFFFFE70U}, + {28, 0xFFFFFE80U}, {24, 0xFFFFEA00U}, {30, 0xFFFFFFF0U}, {28, 0xFFFFFE90U}, + {28, 0xFFFFFEA0U}, {30, 0xFFFFFFF4U}, {28, 0xFFFFFEB0U}, {28, 0xFFFFFEC0U}, + {28, 0xFFFFFED0U}, {28, 0xFFFFFEE0U}, {28, 0xFFFFFEF0U}, {28, 0xFFFFFF00U}, + {28, 0xFFFFFF10U}, {28, 0xFFFFFF20U}, {30, 0xFFFFFFF8U}, {28, 0xFFFFFF30U}, + {28, 0xFFFFFF40U}, {28, 0xFFFFFF50U}, {28, 0xFFFFFF60U}, {28, 0xFFFFFF70U}, + {28, 0xFFFFFF80U}, {28, 0xFFFFFF90U}, {28, 0xFFFFFFA0U}, {28, 0xFFFFFFB0U}, + {6, 0x50000000U}, {10, 0xFE000000U}, {10, 0xFE400000U}, {12, 0xFFA00000U}, + {13, 0xFFC80000U}, {6, 0x54000000U}, {8, 0xF8000000U}, {11, 0xFF400000U}, + {10, 0xFE800000U}, {10, 0xFEC00000U}, {8, 0xF9000000U}, {11, 0xFF600000U}, + {8, 0xFA000000U}, {6, 0x58000000U}, {6, 0x5C000000U}, {6, 0x60000000U}, + {5, 0x0U}, {5, 0x8000000U}, {5, 0x10000000U}, {6, 0x64000000U}, + {6, 0x68000000U}, {6, 0x6C000000U}, {6, 0x70000000U}, {6, 0x74000000U}, + {6, 0x78000000U}, {6, 0x7C000000U}, {7, 0xB8000000U}, {8, 0xFB000000U}, + {15, 0xFFF80000U}, {6, 0x80000000U}, {12, 0xFFB00000U}, {10, 0xFF000000U}, + {13, 0xFFD00000U}, {6, 0x84000000U}, {7, 0xBA000000U}, {7, 0xBC000000U}, + {7, 0xBE000000U}, {7, 0xC0000000U}, {7, 0xC2000000U}, {7, 0xC4000000U}, + {7, 0xC6000000U}, {7, 0xC8000000U}, {7, 0xCA000000U}, {7, 0xCC000000U}, + {7, 0xCE000000U}, {7, 0xD0000000U}, {7, 0xD2000000U}, {7, 0xD4000000U}, + {7, 0xD6000000U}, {7, 0xD8000000U}, {7, 0xDA000000U}, {7, 0xDC000000U}, + {7, 0xDE000000U}, {7, 0xE0000000U}, {7, 0xE2000000U}, {7, 0xE4000000U}, + {8, 0xFC000000U}, {7, 0xE6000000U}, {8, 0xFD000000U}, {13, 0xFFD80000U}, + {19, 0xFFFE0000U}, {13, 0xFFE00000U}, {14, 0xFFF00000U}, {6, 0x88000000U}, + {15, 0xFFFA0000U}, {5, 0x18000000U}, {6, 0x8C000000U}, {5, 0x20000000U}, + {6, 0x90000000U}, {5, 0x28000000U}, {6, 0x94000000U}, {6, 0x98000000U}, + {6, 0x9C000000U}, {5, 0x30000000U}, {7, 0xE8000000U}, {7, 0xEA000000U}, + {6, 0xA0000000U}, {6, 0xA4000000U}, {6, 0xA8000000U}, {5, 0x38000000U}, + {6, 0xAC000000U}, {7, 0xEC000000U}, {6, 0xB0000000U}, {5, 0x40000000U}, + {5, 0x48000000U}, {6, 0xB4000000U}, {7, 0xEE000000U}, {7, 0xF0000000U}, + {7, 0xF2000000U}, {7, 0xF4000000U}, {7, 0xF6000000U}, {15, 0xFFFC0000U}, + {11, 0xFF800000U}, {14, 0xFFF40000U}, {13, 0xFFE80000U}, {28, 0xFFFFFFC0U}, + {20, 0xFFFE6000U}, {22, 0xFFFF4800U}, {20, 0xFFFE7000U}, {20, 0xFFFE8000U}, + {22, 0xFFFF4C00U}, {22, 0xFFFF5000U}, {22, 0xFFFF5400U}, {23, 0xFFFFB200U}, + {22, 0xFFFF5800U}, {23, 0xFFFFB400U}, {23, 0xFFFFB600U}, {23, 0xFFFFB800U}, + {23, 0xFFFFBA00U}, {23, 0xFFFFBC00U}, {24, 0xFFFFEB00U}, {23, 0xFFFFBE00U}, + {24, 0xFFFFEC00U}, {24, 0xFFFFED00U}, {22, 0xFFFF5C00U}, {23, 0xFFFFC000U}, + {24, 0xFFFFEE00U}, {23, 0xFFFFC200U}, {23, 0xFFFFC400U}, {23, 0xFFFFC600U}, + {23, 0xFFFFC800U}, {21, 0xFFFEE000U}, {22, 0xFFFF6000U}, {23, 0xFFFFCA00U}, + {22, 0xFFFF6400U}, {23, 0xFFFFCC00U}, {23, 0xFFFFCE00U}, {24, 0xFFFFEF00U}, + {22, 0xFFFF6800U}, {21, 0xFFFEE800U}, {20, 0xFFFE9000U}, {22, 0xFFFF6C00U}, + {22, 0xFFFF7000U}, {23, 0xFFFFD000U}, {23, 0xFFFFD200U}, {21, 0xFFFEF000U}, + {23, 0xFFFFD400U}, {22, 0xFFFF7400U}, {22, 0xFFFF7800U}, {24, 0xFFFFF000U}, + {21, 0xFFFEF800U}, {22, 0xFFFF7C00U}, {23, 0xFFFFD600U}, {23, 0xFFFFD800U}, + {21, 0xFFFF0000U}, {21, 0xFFFF0800U}, {22, 0xFFFF8000U}, {21, 0xFFFF1000U}, + {23, 0xFFFFDA00U}, {22, 0xFFFF8400U}, {23, 0xFFFFDC00U}, {23, 0xFFFFDE00U}, + {20, 0xFFFEA000U}, {22, 0xFFFF8800U}, {22, 0xFFFF8C00U}, {22, 0xFFFF9000U}, + {23, 0xFFFFE000U}, {22, 0xFFFF9400U}, {22, 0xFFFF9800U}, {23, 0xFFFFE200U}, + {26, 0xFFFFF800U}, {26, 0xFFFFF840U}, {20, 0xFFFEB000U}, {19, 0xFFFE2000U}, + {22, 0xFFFF9C00U}, {23, 0xFFFFE400U}, {22, 0xFFFFA000U}, {25, 0xFFFFF600U}, + {26, 0xFFFFF880U}, {26, 0xFFFFF8C0U}, {26, 0xFFFFF900U}, {27, 0xFFFFFBC0U}, + {27, 0xFFFFFBE0U}, {26, 0xFFFFF940U}, {24, 0xFFFFF100U}, {25, 0xFFFFF680U}, + {19, 0xFFFE4000U}, {21, 0xFFFF1800U}, {26, 0xFFFFF980U}, {27, 0xFFFFFC00U}, + {27, 0xFFFFFC20U}, {26, 0xFFFFF9C0U}, {27, 0xFFFFFC40U}, {24, 0xFFFFF200U}, + {21, 0xFFFF2000U}, {21, 0xFFFF2800U}, {26, 0xFFFFFA00U}, {26, 0xFFFFFA40U}, + {28, 0xFFFFFFD0U}, {27, 0xFFFFFC60U}, {27, 0xFFFFFC80U}, {27, 0xFFFFFCA0U}, + {20, 0xFFFEC000U}, {24, 0xFFFFF300U}, {20, 0xFFFED000U}, {21, 0xFFFF3000U}, + {22, 0xFFFFA400U}, {21, 0xFFFF3800U}, {21, 0xFFFF4000U}, {23, 0xFFFFE600U}, + {22, 0xFFFFA800U}, {22, 0xFFFFAC00U}, {25, 0xFFFFF700U}, {25, 0xFFFFF780U}, + {24, 0xFFFFF400U}, {24, 0xFFFFF500U}, {26, 0xFFFFFA80U}, {23, 0xFFFFE800U}, + {26, 0xFFFFFAC0U}, {27, 0xFFFFFCC0U}, {26, 0xFFFFFB00U}, {26, 0xFFFFFB40U}, + {27, 0xFFFFFCE0U}, {27, 0xFFFFFD00U}, {27, 0xFFFFFD20U}, {27, 0xFFFFFD40U}, + {27, 0xFFFFFD60U}, {28, 0xFFFFFFE0U}, {27, 0xFFFFFD80U}, {27, 0xFFFFFDA0U}, + {27, 0xFFFFFDC0U}, {27, 0xFFFFFDE0U}, {27, 0xFFFFFE00U}, {26, 0xFFFFFB80U}, + {30, 0xFFFFFFFCU}}; const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { /* 0 */ @@ -101,15 +101,15 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x05, 0, 0}, {0x07, 0, 0}, {0x08, 0, 0}, - {0x0b, 0, 0}, - {0x0c, 0, 0}, + {0x0B, 0, 0}, + {0x0C, 0, 0}, {0x10, 0, 0}, {0x13, 0, 0}, {0x19, 0, 0}, - {0x1c, 0, 0}, + {0x1C, 0, 0}, {0x20, 0, 0}, {0x23, 0, 0}, - {0x2a, 0, 0}, + {0x2A, 0, 0}, {0x31, 0, 0}, {0x39, 0, 0}, {0x40, 1, 0}, @@ -126,8 +126,8 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x00, 3, 111}, {0x00, 3, 115}, {0x00, 3, 116}, - {0x0d, 0, 0}, - {0x0e, 0, 0}, + {0x0D, 0, 0}, + {0x0E, 0, 0}, {0x11, 0, 0}, {0x12, 0, 0}, {0x14, 0, 0}, @@ -175,18 +175,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 48}, {0x06, 2, 48}, - {0x0a, 2, 48}, - {0x0f, 2, 48}, + {0x0A, 2, 48}, + {0x0F, 2, 48}, {0x18, 2, 48}, - {0x1f, 2, 48}, + {0x1F, 2, 48}, {0x29, 2, 48}, {0x38, 3, 48}, {0x03, 2, 49}, {0x06, 2, 49}, - {0x0a, 2, 49}, - {0x0f, 2, 49}, + {0x0A, 2, 49}, + {0x0F, 2, 49}, {0x18, 2, 49}, - {0x1f, 2, 49}, + {0x1F, 2, 49}, {0x29, 2, 49}, {0x38, 3, 49}, }, @@ -194,18 +194,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 50}, {0x06, 2, 50}, - {0x0a, 2, 50}, - {0x0f, 2, 50}, + {0x0A, 2, 50}, + {0x0F, 2, 50}, {0x18, 2, 50}, - {0x1f, 2, 50}, + {0x1F, 2, 50}, {0x29, 2, 50}, {0x38, 3, 50}, {0x03, 2, 97}, {0x06, 2, 97}, - {0x0a, 2, 97}, - {0x0f, 2, 97}, + {0x0A, 2, 97}, + {0x0F, 2, 97}, {0x18, 2, 97}, - {0x1f, 2, 97}, + {0x1F, 2, 97}, {0x29, 2, 97}, {0x38, 3, 97}, }, @@ -232,18 +232,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 99}, {0x06, 2, 99}, - {0x0a, 2, 99}, - {0x0f, 2, 99}, + {0x0A, 2, 99}, + {0x0F, 2, 99}, {0x18, 2, 99}, - {0x1f, 2, 99}, + {0x1F, 2, 99}, {0x29, 2, 99}, {0x38, 3, 99}, {0x03, 2, 101}, {0x06, 2, 101}, - {0x0a, 2, 101}, - {0x0f, 2, 101}, + {0x0A, 2, 101}, + {0x0F, 2, 101}, {0x18, 2, 101}, - {0x1f, 2, 101}, + {0x1F, 2, 101}, {0x29, 2, 101}, {0x38, 3, 101}, }, @@ -251,18 +251,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 105}, {0x06, 2, 105}, - {0x0a, 2, 105}, - {0x0f, 2, 105}, + {0x0A, 2, 105}, + {0x0F, 2, 105}, {0x18, 2, 105}, - {0x1f, 2, 105}, + {0x1F, 2, 105}, {0x29, 2, 105}, {0x38, 3, 105}, {0x03, 2, 111}, {0x06, 2, 111}, - {0x0a, 2, 111}, - {0x0f, 2, 111}, + {0x0A, 2, 111}, + {0x0F, 2, 111}, {0x18, 2, 111}, - {0x1f, 2, 111}, + {0x1F, 2, 111}, {0x29, 2, 111}, {0x38, 3, 111}, }, @@ -308,18 +308,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 115}, {0x06, 2, 115}, - {0x0a, 2, 115}, - {0x0f, 2, 115}, + {0x0A, 2, 115}, + {0x0F, 2, 115}, {0x18, 2, 115}, - {0x1f, 2, 115}, + {0x1F, 2, 115}, {0x29, 2, 115}, {0x38, 3, 115}, {0x03, 2, 116}, {0x06, 2, 116}, - {0x0a, 2, 116}, - {0x0f, 2, 116}, + {0x0A, 2, 116}, + {0x0F, 2, 116}, {0x18, 2, 116}, - {0x1f, 2, 116}, + {0x1F, 2, 116}, {0x29, 2, 116}, {0x38, 3, 116}, }, @@ -346,18 +346,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 32}, {0x06, 2, 32}, - {0x0a, 2, 32}, - {0x0f, 2, 32}, + {0x0A, 2, 32}, + {0x0F, 2, 32}, {0x18, 2, 32}, - {0x1f, 2, 32}, + {0x1F, 2, 32}, {0x29, 2, 32}, {0x38, 3, 32}, {0x03, 2, 37}, {0x06, 2, 37}, - {0x0a, 2, 37}, - {0x0f, 2, 37}, + {0x0A, 2, 37}, + {0x0F, 2, 37}, {0x18, 2, 37}, - {0x1f, 2, 37}, + {0x1F, 2, 37}, {0x29, 2, 37}, {0x38, 3, 37}, }, @@ -365,18 +365,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 45}, {0x06, 2, 45}, - {0x0a, 2, 45}, - {0x0f, 2, 45}, + {0x0A, 2, 45}, + {0x0F, 2, 45}, {0x18, 2, 45}, - {0x1f, 2, 45}, + {0x1F, 2, 45}, {0x29, 2, 45}, {0x38, 3, 45}, {0x03, 2, 46}, {0x06, 2, 46}, - {0x0a, 2, 46}, - {0x0f, 2, 46}, + {0x0A, 2, 46}, + {0x0F, 2, 46}, {0x18, 2, 46}, - {0x1f, 2, 46}, + {0x1F, 2, 46}, {0x29, 2, 46}, {0x38, 3, 46}, }, @@ -422,18 +422,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 47}, {0x06, 2, 47}, - {0x0a, 2, 47}, - {0x0f, 2, 47}, + {0x0A, 2, 47}, + {0x0F, 2, 47}, {0x18, 2, 47}, - {0x1f, 2, 47}, + {0x1F, 2, 47}, {0x29, 2, 47}, {0x38, 3, 47}, {0x03, 2, 51}, {0x06, 2, 51}, - {0x0a, 2, 51}, - {0x0f, 2, 51}, + {0x0A, 2, 51}, + {0x0F, 2, 51}, {0x18, 2, 51}, - {0x1f, 2, 51}, + {0x1F, 2, 51}, {0x29, 2, 51}, {0x38, 3, 51}, }, @@ -441,18 +441,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 52}, {0x06, 2, 52}, - {0x0a, 2, 52}, - {0x0f, 2, 52}, + {0x0A, 2, 52}, + {0x0F, 2, 52}, {0x18, 2, 52}, - {0x1f, 2, 52}, + {0x1F, 2, 52}, {0x29, 2, 52}, {0x38, 3, 52}, {0x03, 2, 53}, {0x06, 2, 53}, - {0x0a, 2, 53}, - {0x0f, 2, 53}, + {0x0A, 2, 53}, + {0x0F, 2, 53}, {0x18, 2, 53}, - {0x1f, 2, 53}, + {0x1F, 2, 53}, {0x29, 2, 53}, {0x38, 3, 53}, }, @@ -479,18 +479,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 54}, {0x06, 2, 54}, - {0x0a, 2, 54}, - {0x0f, 2, 54}, + {0x0A, 2, 54}, + {0x0F, 2, 54}, {0x18, 2, 54}, - {0x1f, 2, 54}, + {0x1F, 2, 54}, {0x29, 2, 54}, {0x38, 3, 54}, {0x03, 2, 55}, {0x06, 2, 55}, - {0x0a, 2, 55}, - {0x0f, 2, 55}, + {0x0A, 2, 55}, + {0x0F, 2, 55}, {0x18, 2, 55}, - {0x1f, 2, 55}, + {0x1F, 2, 55}, {0x29, 2, 55}, {0x38, 3, 55}, }, @@ -498,37 +498,37 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 56}, {0x06, 2, 56}, - {0x0a, 2, 56}, - {0x0f, 2, 56}, + {0x0A, 2, 56}, + {0x0F, 2, 56}, {0x18, 2, 56}, - {0x1f, 2, 56}, + {0x1F, 2, 56}, {0x29, 2, 56}, {0x38, 3, 56}, {0x03, 2, 57}, {0x06, 2, 57}, - {0x0a, 2, 57}, - {0x0f, 2, 57}, + {0x0A, 2, 57}, + {0x0F, 2, 57}, {0x18, 2, 57}, - {0x1f, 2, 57}, + {0x1F, 2, 57}, {0x29, 2, 57}, {0x38, 3, 57}, }, /* 22 */ { - {0x1a, 0, 0}, - {0x1b, 0, 0}, - {0x1d, 0, 0}, - {0x1e, 0, 0}, + {0x1A, 0, 0}, + {0x1B, 0, 0}, + {0x1D, 0, 0}, + {0x1E, 0, 0}, {0x21, 0, 0}, {0x22, 0, 0}, {0x24, 0, 0}, {0x25, 0, 0}, - {0x2b, 0, 0}, - {0x2e, 0, 0}, + {0x2B, 0, 0}, + {0x2E, 0, 0}, {0x32, 0, 0}, {0x35, 0, 0}, - {0x3a, 0, 0}, - {0x3d, 0, 0}, + {0x3A, 0, 0}, + {0x3D, 0, 0}, {0x41, 0, 0}, {0x44, 1, 0}, }, @@ -593,18 +593,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 61}, {0x06, 2, 61}, - {0x0a, 2, 61}, - {0x0f, 2, 61}, + {0x0A, 2, 61}, + {0x0F, 2, 61}, {0x18, 2, 61}, - {0x1f, 2, 61}, + {0x1F, 2, 61}, {0x29, 2, 61}, {0x38, 3, 61}, {0x03, 2, 65}, {0x06, 2, 65}, - {0x0a, 2, 65}, - {0x0f, 2, 65}, + {0x0A, 2, 65}, + {0x0F, 2, 65}, {0x18, 2, 65}, - {0x1f, 2, 65}, + {0x1F, 2, 65}, {0x29, 2, 65}, {0x38, 3, 65}, }, @@ -612,18 +612,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 95}, {0x06, 2, 95}, - {0x0a, 2, 95}, - {0x0f, 2, 95}, + {0x0A, 2, 95}, + {0x0F, 2, 95}, {0x18, 2, 95}, - {0x1f, 2, 95}, + {0x1F, 2, 95}, {0x29, 2, 95}, {0x38, 3, 95}, {0x03, 2, 98}, {0x06, 2, 98}, - {0x0a, 2, 98}, - {0x0f, 2, 98}, + {0x0A, 2, 98}, + {0x0F, 2, 98}, {0x18, 2, 98}, - {0x1f, 2, 98}, + {0x1F, 2, 98}, {0x29, 2, 98}, {0x38, 3, 98}, }, @@ -650,18 +650,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 100}, {0x06, 2, 100}, - {0x0a, 2, 100}, - {0x0f, 2, 100}, + {0x0A, 2, 100}, + {0x0F, 2, 100}, {0x18, 2, 100}, - {0x1f, 2, 100}, + {0x1F, 2, 100}, {0x29, 2, 100}, {0x38, 3, 100}, {0x03, 2, 102}, {0x06, 2, 102}, - {0x0a, 2, 102}, - {0x0f, 2, 102}, + {0x0A, 2, 102}, + {0x0F, 2, 102}, {0x18, 2, 102}, - {0x1f, 2, 102}, + {0x1F, 2, 102}, {0x29, 2, 102}, {0x38, 3, 102}, }, @@ -669,18 +669,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 103}, {0x06, 2, 103}, - {0x0a, 2, 103}, - {0x0f, 2, 103}, + {0x0A, 2, 103}, + {0x0F, 2, 103}, {0x18, 2, 103}, - {0x1f, 2, 103}, + {0x1F, 2, 103}, {0x29, 2, 103}, {0x38, 3, 103}, {0x03, 2, 104}, {0x06, 2, 104}, - {0x0a, 2, 104}, - {0x0f, 2, 104}, + {0x0A, 2, 104}, + {0x0F, 2, 104}, {0x18, 2, 104}, - {0x1f, 2, 104}, + {0x1F, 2, 104}, {0x29, 2, 104}, {0x38, 3, 104}, }, @@ -726,18 +726,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 108}, {0x06, 2, 108}, - {0x0a, 2, 108}, - {0x0f, 2, 108}, + {0x0A, 2, 108}, + {0x0F, 2, 108}, {0x18, 2, 108}, - {0x1f, 2, 108}, + {0x1F, 2, 108}, {0x29, 2, 108}, {0x38, 3, 108}, {0x03, 2, 109}, {0x06, 2, 109}, - {0x0a, 2, 109}, - {0x0f, 2, 109}, + {0x0A, 2, 109}, + {0x0F, 2, 109}, {0x18, 2, 109}, - {0x1f, 2, 109}, + {0x1F, 2, 109}, {0x29, 2, 109}, {0x38, 3, 109}, }, @@ -745,18 +745,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 110}, {0x06, 2, 110}, - {0x0a, 2, 110}, - {0x0f, 2, 110}, + {0x0A, 2, 110}, + {0x0F, 2, 110}, {0x18, 2, 110}, - {0x1f, 2, 110}, + {0x1F, 2, 110}, {0x29, 2, 110}, {0x38, 3, 110}, {0x03, 2, 112}, {0x06, 2, 112}, - {0x0a, 2, 112}, - {0x0f, 2, 112}, + {0x0A, 2, 112}, + {0x0F, 2, 112}, {0x18, 2, 112}, - {0x1f, 2, 112}, + {0x1F, 2, 112}, {0x29, 2, 112}, {0x38, 3, 112}, }, @@ -783,18 +783,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 114}, {0x06, 2, 114}, - {0x0a, 2, 114}, - {0x0f, 2, 114}, + {0x0A, 2, 114}, + {0x0F, 2, 114}, {0x18, 2, 114}, - {0x1f, 2, 114}, + {0x1F, 2, 114}, {0x29, 2, 114}, {0x38, 3, 114}, {0x03, 2, 117}, {0x06, 2, 117}, - {0x0a, 2, 117}, - {0x0f, 2, 117}, + {0x0A, 2, 117}, + {0x0F, 2, 117}, {0x18, 2, 117}, - {0x1f, 2, 117}, + {0x1F, 2, 117}, {0x29, 2, 117}, {0x38, 3, 117}, }, @@ -821,18 +821,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 58}, {0x06, 2, 58}, - {0x0a, 2, 58}, - {0x0f, 2, 58}, + {0x0A, 2, 58}, + {0x0F, 2, 58}, {0x18, 2, 58}, - {0x1f, 2, 58}, + {0x1F, 2, 58}, {0x29, 2, 58}, {0x38, 3, 58}, {0x03, 2, 66}, {0x06, 2, 66}, - {0x0a, 2, 66}, - {0x0f, 2, 66}, + {0x0A, 2, 66}, + {0x0F, 2, 66}, {0x18, 2, 66}, - {0x1f, 2, 66}, + {0x1F, 2, 66}, {0x29, 2, 66}, {0x38, 3, 66}, }, @@ -840,35 +840,35 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 67}, {0x06, 2, 67}, - {0x0a, 2, 67}, - {0x0f, 2, 67}, + {0x0A, 2, 67}, + {0x0F, 2, 67}, {0x18, 2, 67}, - {0x1f, 2, 67}, + {0x1F, 2, 67}, {0x29, 2, 67}, {0x38, 3, 67}, {0x03, 2, 68}, {0x06, 2, 68}, - {0x0a, 2, 68}, - {0x0f, 2, 68}, + {0x0A, 2, 68}, + {0x0F, 2, 68}, {0x18, 2, 68}, - {0x1f, 2, 68}, + {0x1F, 2, 68}, {0x29, 2, 68}, {0x38, 3, 68}, }, /* 40 */ { - {0x2c, 0, 0}, - {0x2d, 0, 0}, - {0x2f, 0, 0}, + {0x2C, 0, 0}, + {0x2D, 0, 0}, + {0x2F, 0, 0}, {0x30, 0, 0}, {0x33, 0, 0}, {0x34, 0, 0}, {0x36, 0, 0}, {0x37, 0, 0}, - {0x3b, 0, 0}, - {0x3c, 0, 0}, - {0x3e, 0, 0}, - {0x3f, 0, 0}, + {0x3B, 0, 0}, + {0x3C, 0, 0}, + {0x3E, 0, 0}, + {0x3F, 0, 0}, {0x42, 0, 0}, {0x43, 0, 0}, {0x45, 0, 0}, @@ -935,18 +935,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 69}, {0x06, 2, 69}, - {0x0a, 2, 69}, - {0x0f, 2, 69}, + {0x0A, 2, 69}, + {0x0F, 2, 69}, {0x18, 2, 69}, - {0x1f, 2, 69}, + {0x1F, 2, 69}, {0x29, 2, 69}, {0x38, 3, 69}, {0x03, 2, 70}, {0x06, 2, 70}, - {0x0a, 2, 70}, - {0x0f, 2, 70}, + {0x0A, 2, 70}, + {0x0F, 2, 70}, {0x18, 2, 70}, - {0x1f, 2, 70}, + {0x1F, 2, 70}, {0x29, 2, 70}, {0x38, 3, 70}, }, @@ -954,18 +954,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 71}, {0x06, 2, 71}, - {0x0a, 2, 71}, - {0x0f, 2, 71}, + {0x0A, 2, 71}, + {0x0F, 2, 71}, {0x18, 2, 71}, - {0x1f, 2, 71}, + {0x1F, 2, 71}, {0x29, 2, 71}, {0x38, 3, 71}, {0x03, 2, 72}, {0x06, 2, 72}, - {0x0a, 2, 72}, - {0x0f, 2, 72}, + {0x0A, 2, 72}, + {0x0F, 2, 72}, {0x18, 2, 72}, - {0x1f, 2, 72}, + {0x1F, 2, 72}, {0x29, 2, 72}, {0x38, 3, 72}, }, @@ -992,18 +992,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 73}, {0x06, 2, 73}, - {0x0a, 2, 73}, - {0x0f, 2, 73}, + {0x0A, 2, 73}, + {0x0F, 2, 73}, {0x18, 2, 73}, - {0x1f, 2, 73}, + {0x1F, 2, 73}, {0x29, 2, 73}, {0x38, 3, 73}, {0x03, 2, 74}, {0x06, 2, 74}, - {0x0a, 2, 74}, - {0x0f, 2, 74}, + {0x0A, 2, 74}, + {0x0F, 2, 74}, {0x18, 2, 74}, - {0x1f, 2, 74}, + {0x1F, 2, 74}, {0x29, 2, 74}, {0x38, 3, 74}, }, @@ -1011,18 +1011,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 75}, {0x06, 2, 75}, - {0x0a, 2, 75}, - {0x0f, 2, 75}, + {0x0A, 2, 75}, + {0x0F, 2, 75}, {0x18, 2, 75}, - {0x1f, 2, 75}, + {0x1F, 2, 75}, {0x29, 2, 75}, {0x38, 3, 75}, {0x03, 2, 76}, {0x06, 2, 76}, - {0x0a, 2, 76}, - {0x0f, 2, 76}, + {0x0A, 2, 76}, + {0x0F, 2, 76}, {0x18, 2, 76}, - {0x1f, 2, 76}, + {0x1F, 2, 76}, {0x29, 2, 76}, {0x38, 3, 76}, }, @@ -1068,18 +1068,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 77}, {0x06, 2, 77}, - {0x0a, 2, 77}, - {0x0f, 2, 77}, + {0x0A, 2, 77}, + {0x0F, 2, 77}, {0x18, 2, 77}, - {0x1f, 2, 77}, + {0x1F, 2, 77}, {0x29, 2, 77}, {0x38, 3, 77}, {0x03, 2, 78}, {0x06, 2, 78}, - {0x0a, 2, 78}, - {0x0f, 2, 78}, + {0x0A, 2, 78}, + {0x0F, 2, 78}, {0x18, 2, 78}, - {0x1f, 2, 78}, + {0x1F, 2, 78}, {0x29, 2, 78}, {0x38, 3, 78}, }, @@ -1087,18 +1087,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 79}, {0x06, 2, 79}, - {0x0a, 2, 79}, - {0x0f, 2, 79}, + {0x0A, 2, 79}, + {0x0F, 2, 79}, {0x18, 2, 79}, - {0x1f, 2, 79}, + {0x1F, 2, 79}, {0x29, 2, 79}, {0x38, 3, 79}, {0x03, 2, 80}, {0x06, 2, 80}, - {0x0a, 2, 80}, - {0x0f, 2, 80}, + {0x0A, 2, 80}, + {0x0F, 2, 80}, {0x18, 2, 80}, - {0x1f, 2, 80}, + {0x1F, 2, 80}, {0x29, 2, 80}, {0x38, 3, 80}, }, @@ -1125,18 +1125,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 81}, {0x06, 2, 81}, - {0x0a, 2, 81}, - {0x0f, 2, 81}, + {0x0A, 2, 81}, + {0x0F, 2, 81}, {0x18, 2, 81}, - {0x1f, 2, 81}, + {0x1F, 2, 81}, {0x29, 2, 81}, {0x38, 3, 81}, {0x03, 2, 82}, {0x06, 2, 82}, - {0x0a, 2, 82}, - {0x0f, 2, 82}, + {0x0A, 2, 82}, + {0x0F, 2, 82}, {0x18, 2, 82}, - {0x1f, 2, 82}, + {0x1F, 2, 82}, {0x29, 2, 82}, {0x38, 3, 82}, }, @@ -1144,18 +1144,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 83}, {0x06, 2, 83}, - {0x0a, 2, 83}, - {0x0f, 2, 83}, + {0x0A, 2, 83}, + {0x0F, 2, 83}, {0x18, 2, 83}, - {0x1f, 2, 83}, + {0x1F, 2, 83}, {0x29, 2, 83}, {0x38, 3, 83}, {0x03, 2, 84}, {0x06, 2, 84}, - {0x0a, 2, 84}, - {0x0f, 2, 84}, + {0x0A, 2, 84}, + {0x0F, 2, 84}, {0x18, 2, 84}, - {0x1f, 2, 84}, + {0x1F, 2, 84}, {0x29, 2, 84}, {0x38, 3, 84}, }, @@ -1176,7 +1176,7 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x46, 0, 0}, {0x47, 0, 0}, {0x49, 0, 0}, - {0x4a, 1, 0}, + {0x4A, 1, 0}, }, /* 57 */ { @@ -1220,18 +1220,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 85}, {0x06, 2, 85}, - {0x0a, 2, 85}, - {0x0f, 2, 85}, + {0x0A, 2, 85}, + {0x0F, 2, 85}, {0x18, 2, 85}, - {0x1f, 2, 85}, + {0x1F, 2, 85}, {0x29, 2, 85}, {0x38, 3, 85}, {0x03, 2, 86}, {0x06, 2, 86}, - {0x0a, 2, 86}, - {0x0f, 2, 86}, + {0x0A, 2, 86}, + {0x0F, 2, 86}, {0x18, 2, 86}, - {0x1f, 2, 86}, + {0x1F, 2, 86}, {0x29, 2, 86}, {0x38, 3, 86}, }, @@ -1239,18 +1239,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 87}, {0x06, 2, 87}, - {0x0a, 2, 87}, - {0x0f, 2, 87}, + {0x0A, 2, 87}, + {0x0F, 2, 87}, {0x18, 2, 87}, - {0x1f, 2, 87}, + {0x1F, 2, 87}, {0x29, 2, 87}, {0x38, 3, 87}, {0x03, 2, 89}, {0x06, 2, 89}, - {0x0a, 2, 89}, - {0x0f, 2, 89}, + {0x0A, 2, 89}, + {0x0F, 2, 89}, {0x18, 2, 89}, - {0x1f, 2, 89}, + {0x1F, 2, 89}, {0x29, 2, 89}, {0x38, 3, 89}, }, @@ -1277,18 +1277,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 106}, {0x06, 2, 106}, - {0x0a, 2, 106}, - {0x0f, 2, 106}, + {0x0A, 2, 106}, + {0x0F, 2, 106}, {0x18, 2, 106}, - {0x1f, 2, 106}, + {0x1F, 2, 106}, {0x29, 2, 106}, {0x38, 3, 106}, {0x03, 2, 107}, {0x06, 2, 107}, - {0x0a, 2, 107}, - {0x0f, 2, 107}, + {0x0A, 2, 107}, + {0x0F, 2, 107}, {0x18, 2, 107}, - {0x1f, 2, 107}, + {0x1F, 2, 107}, {0x29, 2, 107}, {0x38, 3, 107}, }, @@ -1296,18 +1296,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 113}, {0x06, 2, 113}, - {0x0a, 2, 113}, - {0x0f, 2, 113}, + {0x0A, 2, 113}, + {0x0F, 2, 113}, {0x18, 2, 113}, - {0x1f, 2, 113}, + {0x1F, 2, 113}, {0x29, 2, 113}, {0x38, 3, 113}, {0x03, 2, 118}, {0x06, 2, 118}, - {0x0a, 2, 118}, - {0x0f, 2, 118}, + {0x0A, 2, 118}, + {0x0F, 2, 118}, {0x18, 2, 118}, - {0x1f, 2, 118}, + {0x1F, 2, 118}, {0x29, 2, 118}, {0x38, 3, 118}, }, @@ -1327,8 +1327,8 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x00, 3, 59}, {0x00, 3, 88}, {0x00, 3, 90}, - {0x4b, 0, 0}, - {0x4e, 0, 0}, + {0x4B, 0, 0}, + {0x4E, 0, 0}, }, /* 65 */ { @@ -1353,18 +1353,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 119}, {0x06, 2, 119}, - {0x0a, 2, 119}, - {0x0f, 2, 119}, + {0x0A, 2, 119}, + {0x0F, 2, 119}, {0x18, 2, 119}, - {0x1f, 2, 119}, + {0x1F, 2, 119}, {0x29, 2, 119}, {0x38, 3, 119}, {0x03, 2, 120}, {0x06, 2, 120}, - {0x0a, 2, 120}, - {0x0f, 2, 120}, + {0x0A, 2, 120}, + {0x0F, 2, 120}, {0x18, 2, 120}, - {0x1f, 2, 120}, + {0x1F, 2, 120}, {0x29, 2, 120}, {0x38, 3, 120}, }, @@ -1372,18 +1372,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 121}, {0x06, 2, 121}, - {0x0a, 2, 121}, - {0x0f, 2, 121}, + {0x0A, 2, 121}, + {0x0F, 2, 121}, {0x18, 2, 121}, - {0x1f, 2, 121}, + {0x1F, 2, 121}, {0x29, 2, 121}, {0x38, 3, 121}, {0x03, 2, 122}, {0x06, 2, 122}, - {0x0a, 2, 122}, - {0x0f, 2, 122}, + {0x0A, 2, 122}, + {0x0F, 2, 122}, {0x18, 2, 122}, - {0x1f, 2, 122}, + {0x1F, 2, 122}, {0x29, 2, 122}, {0x38, 3, 122}, }, @@ -1401,9 +1401,9 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x16, 3, 88}, {0x01, 2, 90}, {0x16, 3, 90}, - {0x4c, 0, 0}, - {0x4d, 0, 0}, - {0x4f, 0, 0}, + {0x4C, 0, 0}, + {0x4D, 0, 0}, + {0x4F, 0, 0}, {0x51, 0, 0}, }, /* 69 */ @@ -1429,18 +1429,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 38}, {0x06, 2, 38}, - {0x0a, 2, 38}, - {0x0f, 2, 38}, + {0x0A, 2, 38}, + {0x0F, 2, 38}, {0x18, 2, 38}, - {0x1f, 2, 38}, + {0x1F, 2, 38}, {0x29, 2, 38}, {0x38, 3, 38}, {0x03, 2, 42}, {0x06, 2, 42}, - {0x0a, 2, 42}, - {0x0f, 2, 42}, + {0x0A, 2, 42}, + {0x0F, 2, 42}, {0x18, 2, 42}, - {0x1f, 2, 42}, + {0x1F, 2, 42}, {0x29, 2, 42}, {0x38, 3, 42}, }, @@ -1448,18 +1448,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 44}, {0x06, 2, 44}, - {0x0a, 2, 44}, - {0x0f, 2, 44}, + {0x0A, 2, 44}, + {0x0F, 2, 44}, {0x18, 2, 44}, - {0x1f, 2, 44}, + {0x1F, 2, 44}, {0x29, 2, 44}, {0x38, 3, 44}, {0x03, 2, 59}, {0x06, 2, 59}, - {0x0a, 2, 59}, - {0x0f, 2, 59}, + {0x0A, 2, 59}, + {0x0F, 2, 59}, {0x18, 2, 59}, - {0x1f, 2, 59}, + {0x1F, 2, 59}, {0x29, 2, 59}, {0x38, 3, 59}, }, @@ -1486,18 +1486,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 88}, {0x06, 2, 88}, - {0x0a, 2, 88}, - {0x0f, 2, 88}, + {0x0A, 2, 88}, + {0x0F, 2, 88}, {0x18, 2, 88}, - {0x1f, 2, 88}, + {0x1F, 2, 88}, {0x29, 2, 88}, {0x38, 3, 88}, {0x03, 2, 90}, {0x06, 2, 90}, - {0x0a, 2, 90}, - {0x0f, 2, 90}, + {0x0A, 2, 90}, + {0x0F, 2, 90}, {0x18, 2, 90}, - {0x1f, 2, 90}, + {0x1F, 2, 90}, {0x29, 2, 90}, {0x38, 3, 90}, }, @@ -1543,18 +1543,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 33}, {0x06, 2, 33}, - {0x0a, 2, 33}, - {0x0f, 2, 33}, + {0x0A, 2, 33}, + {0x0F, 2, 33}, {0x18, 2, 33}, - {0x1f, 2, 33}, + {0x1F, 2, 33}, {0x29, 2, 33}, {0x38, 3, 33}, {0x03, 2, 34}, {0x06, 2, 34}, - {0x0a, 2, 34}, - {0x0f, 2, 34}, + {0x0A, 2, 34}, + {0x0F, 2, 34}, {0x18, 2, 34}, - {0x1f, 2, 34}, + {0x1F, 2, 34}, {0x29, 2, 34}, {0x38, 3, 34}, }, @@ -1562,18 +1562,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 40}, {0x06, 2, 40}, - {0x0a, 2, 40}, - {0x0f, 2, 40}, + {0x0A, 2, 40}, + {0x0F, 2, 40}, {0x18, 2, 40}, - {0x1f, 2, 40}, + {0x1F, 2, 40}, {0x29, 2, 40}, {0x38, 3, 40}, {0x03, 2, 41}, {0x06, 2, 41}, - {0x0a, 2, 41}, - {0x0f, 2, 41}, + {0x0A, 2, 41}, + {0x0F, 2, 41}, {0x18, 2, 41}, - {0x1f, 2, 41}, + {0x1F, 2, 41}, {0x29, 2, 41}, {0x38, 3, 41}, }, @@ -1594,16 +1594,16 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x56, 0, 0}, {0x57, 0, 0}, {0x59, 0, 0}, - {0x5a, 0, 0}, + {0x5A, 0, 0}, }, /* 79 */ { {0x03, 2, 63}, {0x06, 2, 63}, - {0x0a, 2, 63}, - {0x0f, 2, 63}, + {0x0A, 2, 63}, + {0x0F, 2, 63}, {0x18, 2, 63}, - {0x1f, 2, 63}, + {0x1F, 2, 63}, {0x29, 2, 63}, {0x38, 3, 63}, {0x02, 2, 39}, @@ -1619,18 +1619,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 39}, {0x06, 2, 39}, - {0x0a, 2, 39}, - {0x0f, 2, 39}, + {0x0A, 2, 39}, + {0x0F, 2, 39}, {0x18, 2, 39}, - {0x1f, 2, 39}, + {0x1F, 2, 39}, {0x29, 2, 39}, {0x38, 3, 39}, {0x03, 2, 43}, {0x06, 2, 43}, - {0x0a, 2, 43}, - {0x0f, 2, 43}, + {0x0A, 2, 43}, + {0x0F, 2, 43}, {0x18, 2, 43}, - {0x1f, 2, 43}, + {0x1F, 2, 43}, {0x29, 2, 43}, {0x38, 3, 43}, }, @@ -1650,17 +1650,17 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x00, 3, 91}, {0x00, 3, 93}, {0x00, 3, 126}, - {0x5b, 0, 0}, - {0x5c, 0, 0}, + {0x5B, 0, 0}, + {0x5C, 0, 0}, }, /* 82 */ { {0x03, 2, 124}, {0x06, 2, 124}, - {0x0a, 2, 124}, - {0x0f, 2, 124}, + {0x0A, 2, 124}, + {0x0F, 2, 124}, {0x18, 2, 124}, - {0x1f, 2, 124}, + {0x1F, 2, 124}, {0x29, 2, 124}, {0x38, 3, 124}, {0x02, 2, 35}, @@ -1676,18 +1676,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 35}, {0x06, 2, 35}, - {0x0a, 2, 35}, - {0x0f, 2, 35}, + {0x0A, 2, 35}, + {0x0F, 2, 35}, {0x18, 2, 35}, - {0x1f, 2, 35}, + {0x1F, 2, 35}, {0x29, 2, 35}, {0x38, 3, 35}, {0x03, 2, 62}, {0x06, 2, 62}, - {0x0a, 2, 62}, - {0x0f, 2, 62}, + {0x0A, 2, 62}, + {0x0F, 2, 62}, {0x18, 2, 62}, - {0x1f, 2, 62}, + {0x1F, 2, 62}, {0x29, 2, 62}, {0x38, 3, 62}, }, @@ -1707,8 +1707,8 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x16, 3, 126}, {0x00, 3, 94}, {0x00, 3, 125}, - {0x5d, 0, 0}, - {0x5e, 0, 0}, + {0x5D, 0, 0}, + {0x5E, 0, 0}, }, /* 85 */ { @@ -1733,18 +1733,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 0}, {0x06, 2, 0}, - {0x0a, 2, 0}, - {0x0f, 2, 0}, + {0x0A, 2, 0}, + {0x0F, 2, 0}, {0x18, 2, 0}, - {0x1f, 2, 0}, + {0x1F, 2, 0}, {0x29, 2, 0}, {0x38, 3, 0}, {0x03, 2, 36}, {0x06, 2, 36}, - {0x0a, 2, 36}, - {0x0f, 2, 36}, + {0x0A, 2, 36}, + {0x0F, 2, 36}, {0x18, 2, 36}, - {0x1f, 2, 36}, + {0x1F, 2, 36}, {0x29, 2, 36}, {0x38, 3, 36}, }, @@ -1752,18 +1752,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 64}, {0x06, 2, 64}, - {0x0a, 2, 64}, - {0x0f, 2, 64}, + {0x0A, 2, 64}, + {0x0F, 2, 64}, {0x18, 2, 64}, - {0x1f, 2, 64}, + {0x1F, 2, 64}, {0x29, 2, 64}, {0x38, 3, 64}, {0x03, 2, 91}, {0x06, 2, 91}, - {0x0a, 2, 91}, - {0x0f, 2, 91}, + {0x0A, 2, 91}, + {0x0F, 2, 91}, {0x18, 2, 91}, - {0x1f, 2, 91}, + {0x1F, 2, 91}, {0x29, 2, 91}, {0x38, 3, 91}, }, @@ -1784,24 +1784,24 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x00, 3, 60}, {0x00, 3, 96}, {0x00, 3, 123}, - {0x5f, 0, 0}, + {0x5F, 0, 0}, }, /* 89 */ { {0x03, 2, 93}, {0x06, 2, 93}, - {0x0a, 2, 93}, - {0x0f, 2, 93}, + {0x0A, 2, 93}, + {0x0F, 2, 93}, {0x18, 2, 93}, - {0x1f, 2, 93}, + {0x1F, 2, 93}, {0x29, 2, 93}, {0x38, 3, 93}, {0x03, 2, 126}, {0x06, 2, 126}, - {0x0a, 2, 126}, - {0x0f, 2, 126}, + {0x0A, 2, 126}, + {0x0F, 2, 126}, {0x18, 2, 126}, - {0x1f, 2, 126}, + {0x1F, 2, 126}, {0x29, 2, 126}, {0x38, 3, 126}, }, @@ -1822,24 +1822,24 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x01, 2, 123}, {0x16, 3, 123}, {0x60, 0, 0}, - {0x6e, 0, 0}, + {0x6E, 0, 0}, }, /* 91 */ { {0x03, 2, 94}, {0x06, 2, 94}, - {0x0a, 2, 94}, - {0x0f, 2, 94}, + {0x0A, 2, 94}, + {0x0F, 2, 94}, {0x18, 2, 94}, - {0x1f, 2, 94}, + {0x1F, 2, 94}, {0x29, 2, 94}, {0x38, 3, 94}, {0x03, 2, 125}, {0x06, 2, 125}, - {0x0a, 2, 125}, - {0x0f, 2, 125}, + {0x0A, 2, 125}, + {0x0F, 2, 125}, {0x18, 2, 125}, - {0x1f, 2, 125}, + {0x1F, 2, 125}, {0x29, 2, 125}, {0x38, 3, 125}, }, @@ -1859,25 +1859,25 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x28, 3, 123}, {0x61, 0, 0}, {0x65, 0, 0}, - {0x6f, 0, 0}, + {0x6F, 0, 0}, {0x85, 0, 0}, }, /* 93 */ { {0x03, 2, 60}, {0x06, 2, 60}, - {0x0a, 2, 60}, - {0x0f, 2, 60}, + {0x0A, 2, 60}, + {0x0F, 2, 60}, {0x18, 2, 60}, - {0x1f, 2, 60}, + {0x1F, 2, 60}, {0x29, 2, 60}, {0x38, 3, 60}, {0x03, 2, 96}, {0x06, 2, 96}, - {0x0a, 2, 96}, - {0x0f, 2, 96}, + {0x0A, 2, 96}, + {0x0F, 2, 96}, {0x18, 2, 96}, - {0x1f, 2, 96}, + {0x1F, 2, 96}, {0x29, 2, 96}, {0x38, 3, 96}, }, @@ -1885,10 +1885,10 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 123}, {0x06, 2, 123}, - {0x0a, 2, 123}, - {0x0f, 2, 123}, + {0x0A, 2, 123}, + {0x0F, 2, 123}, {0x18, 2, 123}, - {0x1f, 2, 123}, + {0x1F, 2, 123}, {0x29, 2, 123}, {0x38, 3, 123}, {0x62, 0, 0}, @@ -1908,16 +1908,16 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x64, 0, 0}, {0x67, 0, 0}, {0x68, 0, 0}, - {0x6a, 0, 0}, - {0x6b, 0, 0}, + {0x6A, 0, 0}, + {0x6B, 0, 0}, {0x71, 0, 0}, {0x74, 0, 0}, {0x78, 0, 0}, - {0x7e, 0, 0}, + {0x7E, 0, 0}, {0x87, 0, 0}, - {0x8e, 0, 0}, - {0x9a, 0, 0}, - {0xa9, 0, 0}, + {0x8E, 0, 0}, + {0x9A, 0, 0}, + {0xA9, 0, 0}, }, /* 96 */ { @@ -1935,8 +1935,8 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x00, 3, 194}, {0x00, 3, 224}, {0x00, 3, 226}, - {0x6c, 0, 0}, - {0x6d, 0, 0}, + {0x6C, 0, 0}, + {0x6D, 0, 0}, }, /* 97 */ { @@ -1961,18 +1961,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 92}, {0x06, 2, 92}, - {0x0a, 2, 92}, - {0x0f, 2, 92}, + {0x0A, 2, 92}, + {0x0F, 2, 92}, {0x18, 2, 92}, - {0x1f, 2, 92}, + {0x1F, 2, 92}, {0x29, 2, 92}, {0x38, 3, 92}, {0x03, 2, 195}, {0x06, 2, 195}, - {0x0a, 2, 195}, - {0x0f, 2, 195}, + {0x0A, 2, 195}, + {0x0F, 2, 195}, {0x18, 2, 195}, - {0x1f, 2, 195}, + {0x1F, 2, 195}, {0x29, 2, 195}, {0x38, 3, 195}, }, @@ -1980,10 +1980,10 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 208}, {0x06, 2, 208}, - {0x0a, 2, 208}, - {0x0f, 2, 208}, + {0x0A, 2, 208}, + {0x0F, 2, 208}, {0x18, 2, 208}, - {0x1f, 2, 208}, + {0x1F, 2, 208}, {0x29, 2, 208}, {0x38, 3, 208}, {0x02, 2, 128}, @@ -1999,18 +1999,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 128}, {0x06, 2, 128}, - {0x0a, 2, 128}, - {0x0f, 2, 128}, + {0x0A, 2, 128}, + {0x0F, 2, 128}, {0x18, 2, 128}, - {0x1f, 2, 128}, + {0x1F, 2, 128}, {0x29, 2, 128}, {0x38, 3, 128}, {0x03, 2, 130}, {0x06, 2, 130}, - {0x0a, 2, 130}, - {0x0f, 2, 130}, + {0x0A, 2, 130}, + {0x0F, 2, 130}, {0x18, 2, 130}, - {0x1f, 2, 130}, + {0x1F, 2, 130}, {0x29, 2, 130}, {0x38, 3, 130}, }, @@ -2056,18 +2056,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 131}, {0x06, 2, 131}, - {0x0a, 2, 131}, - {0x0f, 2, 131}, + {0x0A, 2, 131}, + {0x0F, 2, 131}, {0x18, 2, 131}, - {0x1f, 2, 131}, + {0x1F, 2, 131}, {0x29, 2, 131}, {0x38, 3, 131}, {0x03, 2, 162}, {0x06, 2, 162}, - {0x0a, 2, 162}, - {0x0f, 2, 162}, + {0x0A, 2, 162}, + {0x0F, 2, 162}, {0x18, 2, 162}, - {0x1f, 2, 162}, + {0x1F, 2, 162}, {0x29, 2, 162}, {0x38, 3, 162}, }, @@ -2075,18 +2075,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 184}, {0x06, 2, 184}, - {0x0a, 2, 184}, - {0x0f, 2, 184}, + {0x0A, 2, 184}, + {0x0F, 2, 184}, {0x18, 2, 184}, - {0x1f, 2, 184}, + {0x1F, 2, 184}, {0x29, 2, 184}, {0x38, 3, 184}, {0x03, 2, 194}, {0x06, 2, 194}, - {0x0a, 2, 194}, - {0x0f, 2, 194}, + {0x0A, 2, 194}, + {0x0F, 2, 194}, {0x18, 2, 194}, - {0x1f, 2, 194}, + {0x1F, 2, 194}, {0x29, 2, 194}, {0x38, 3, 194}, }, @@ -2113,18 +2113,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 224}, {0x06, 2, 224}, - {0x0a, 2, 224}, - {0x0f, 2, 224}, + {0x0A, 2, 224}, + {0x0F, 2, 224}, {0x18, 2, 224}, - {0x1f, 2, 224}, + {0x1F, 2, 224}, {0x29, 2, 224}, {0x38, 3, 224}, {0x03, 2, 226}, {0x06, 2, 226}, - {0x0a, 2, 226}, - {0x0f, 2, 226}, + {0x0A, 2, 226}, + {0x0F, 2, 226}, {0x18, 2, 226}, - {0x1f, 2, 226}, + {0x1F, 2, 226}, {0x29, 2, 226}, {0x38, 3, 226}, }, @@ -2151,18 +2151,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 153}, {0x06, 2, 153}, - {0x0a, 2, 153}, - {0x0f, 2, 153}, + {0x0A, 2, 153}, + {0x0F, 2, 153}, {0x18, 2, 153}, - {0x1f, 2, 153}, + {0x1F, 2, 153}, {0x29, 2, 153}, {0x38, 3, 153}, {0x03, 2, 161}, {0x06, 2, 161}, - {0x0a, 2, 161}, - {0x0f, 2, 161}, + {0x0A, 2, 161}, + {0x0F, 2, 161}, {0x18, 2, 161}, - {0x1f, 2, 161}, + {0x1F, 2, 161}, {0x29, 2, 161}, {0x38, 3, 161}, }, @@ -2170,18 +2170,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 167}, {0x06, 2, 167}, - {0x0a, 2, 167}, - {0x0f, 2, 167}, + {0x0A, 2, 167}, + {0x0F, 2, 167}, {0x18, 2, 167}, - {0x1f, 2, 167}, + {0x1F, 2, 167}, {0x29, 2, 167}, {0x38, 3, 167}, {0x03, 2, 172}, {0x06, 2, 172}, - {0x0a, 2, 172}, - {0x0f, 2, 172}, + {0x0A, 2, 172}, + {0x0F, 2, 172}, {0x18, 2, 172}, - {0x1f, 2, 172}, + {0x1F, 2, 172}, {0x29, 2, 172}, {0x38, 3, 172}, }, @@ -2192,17 +2192,17 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x75, 0, 0}, {0x76, 0, 0}, {0x79, 0, 0}, - {0x7b, 0, 0}, - {0x7f, 0, 0}, + {0x7B, 0, 0}, + {0x7F, 0, 0}, {0x82, 0, 0}, {0x88, 0, 0}, - {0x8b, 0, 0}, - {0x8f, 0, 0}, + {0x8B, 0, 0}, + {0x8F, 0, 0}, {0x92, 0, 0}, - {0x9b, 0, 0}, - {0xa2, 0, 0}, - {0xaa, 0, 0}, - {0xb4, 0, 0}, + {0x9B, 0, 0}, + {0xA2, 0, 0}, + {0xAA, 0, 0}, + {0xB4, 0, 0}, }, /* 111 */ { @@ -2215,9 +2215,9 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x00, 3, 227}, {0x00, 3, 229}, {0x00, 3, 230}, - {0x7a, 0, 0}, - {0x7c, 0, 0}, - {0x7d, 0, 0}, + {0x7A, 0, 0}, + {0x7C, 0, 0}, + {0x7D, 0, 0}, {0x80, 0, 0}, {0x81, 0, 0}, {0x83, 0, 0}, @@ -2265,18 +2265,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 176}, {0x06, 2, 176}, - {0x0a, 2, 176}, - {0x0f, 2, 176}, + {0x0A, 2, 176}, + {0x0F, 2, 176}, {0x18, 2, 176}, - {0x1f, 2, 176}, + {0x1F, 2, 176}, {0x29, 2, 176}, {0x38, 3, 176}, {0x03, 2, 177}, {0x06, 2, 177}, - {0x0a, 2, 177}, - {0x0f, 2, 177}, + {0x0A, 2, 177}, + {0x0F, 2, 177}, {0x18, 2, 177}, - {0x1f, 2, 177}, + {0x1F, 2, 177}, {0x29, 2, 177}, {0x38, 3, 177}, }, @@ -2284,18 +2284,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 179}, {0x06, 2, 179}, - {0x0a, 2, 179}, - {0x0f, 2, 179}, + {0x0A, 2, 179}, + {0x0F, 2, 179}, {0x18, 2, 179}, - {0x1f, 2, 179}, + {0x1F, 2, 179}, {0x29, 2, 179}, {0x38, 3, 179}, {0x03, 2, 209}, {0x06, 2, 209}, - {0x0a, 2, 209}, - {0x0f, 2, 209}, + {0x0A, 2, 209}, + {0x0F, 2, 209}, {0x18, 2, 209}, - {0x1f, 2, 209}, + {0x1F, 2, 209}, {0x29, 2, 209}, {0x38, 3, 209}, }, @@ -2322,18 +2322,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 216}, {0x06, 2, 216}, - {0x0a, 2, 216}, - {0x0f, 2, 216}, + {0x0A, 2, 216}, + {0x0F, 2, 216}, {0x18, 2, 216}, - {0x1f, 2, 216}, + {0x1F, 2, 216}, {0x29, 2, 216}, {0x38, 3, 216}, {0x03, 2, 217}, {0x06, 2, 217}, - {0x0a, 2, 217}, - {0x0f, 2, 217}, + {0x0A, 2, 217}, + {0x0F, 2, 217}, {0x18, 2, 217}, - {0x1f, 2, 217}, + {0x1F, 2, 217}, {0x29, 2, 217}, {0x38, 3, 217}, }, @@ -2341,18 +2341,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 227}, {0x06, 2, 227}, - {0x0a, 2, 227}, - {0x0f, 2, 227}, + {0x0A, 2, 227}, + {0x0F, 2, 227}, {0x18, 2, 227}, - {0x1f, 2, 227}, + {0x1F, 2, 227}, {0x29, 2, 227}, {0x38, 3, 227}, {0x03, 2, 229}, {0x06, 2, 229}, - {0x0a, 2, 229}, - {0x0f, 2, 229}, + {0x0A, 2, 229}, + {0x0F, 2, 229}, {0x18, 2, 229}, - {0x1f, 2, 229}, + {0x1F, 2, 229}, {0x29, 2, 229}, {0x38, 3, 229}, }, @@ -2398,10 +2398,10 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 230}, {0x06, 2, 230}, - {0x0a, 2, 230}, - {0x0f, 2, 230}, + {0x0A, 2, 230}, + {0x0F, 2, 230}, {0x18, 2, 230}, - {0x1f, 2, 230}, + {0x1F, 2, 230}, {0x29, 2, 230}, {0x38, 3, 230}, {0x02, 2, 129}, @@ -2417,18 +2417,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 129}, {0x06, 2, 129}, - {0x0a, 2, 129}, - {0x0f, 2, 129}, + {0x0A, 2, 129}, + {0x0F, 2, 129}, {0x18, 2, 129}, - {0x1f, 2, 129}, + {0x1F, 2, 129}, {0x29, 2, 129}, {0x38, 3, 129}, {0x03, 2, 132}, {0x06, 2, 132}, - {0x0a, 2, 132}, - {0x0f, 2, 132}, + {0x0A, 2, 132}, + {0x0F, 2, 132}, {0x18, 2, 132}, - {0x1f, 2, 132}, + {0x1F, 2, 132}, {0x29, 2, 132}, {0x38, 3, 132}, }, @@ -2455,18 +2455,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 133}, {0x06, 2, 133}, - {0x0a, 2, 133}, - {0x0f, 2, 133}, + {0x0A, 2, 133}, + {0x0F, 2, 133}, {0x18, 2, 133}, - {0x1f, 2, 133}, + {0x1F, 2, 133}, {0x29, 2, 133}, {0x38, 3, 133}, {0x03, 2, 134}, {0x06, 2, 134}, - {0x0a, 2, 134}, - {0x0f, 2, 134}, + {0x0A, 2, 134}, + {0x0F, 2, 134}, {0x18, 2, 134}, - {0x1f, 2, 134}, + {0x1F, 2, 134}, {0x29, 2, 134}, {0x38, 3, 134}, }, @@ -2474,18 +2474,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 136}, {0x06, 2, 136}, - {0x0a, 2, 136}, - {0x0f, 2, 136}, + {0x0A, 2, 136}, + {0x0F, 2, 136}, {0x18, 2, 136}, - {0x1f, 2, 136}, + {0x1F, 2, 136}, {0x29, 2, 136}, {0x38, 3, 136}, {0x03, 2, 146}, {0x06, 2, 146}, - {0x0a, 2, 146}, - {0x0f, 2, 146}, + {0x0A, 2, 146}, + {0x0F, 2, 146}, {0x18, 2, 146}, - {0x1f, 2, 146}, + {0x1F, 2, 146}, {0x29, 2, 146}, {0x38, 3, 146}, }, @@ -2531,18 +2531,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 154}, {0x06, 2, 154}, - {0x0a, 2, 154}, - {0x0f, 2, 154}, + {0x0A, 2, 154}, + {0x0F, 2, 154}, {0x18, 2, 154}, - {0x1f, 2, 154}, + {0x1F, 2, 154}, {0x29, 2, 154}, {0x38, 3, 154}, {0x03, 2, 156}, {0x06, 2, 156}, - {0x0a, 2, 156}, - {0x0f, 2, 156}, + {0x0A, 2, 156}, + {0x0F, 2, 156}, {0x18, 2, 156}, - {0x1f, 2, 156}, + {0x1F, 2, 156}, {0x29, 2, 156}, {0x38, 3, 156}, }, @@ -2550,18 +2550,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 160}, {0x06, 2, 160}, - {0x0a, 2, 160}, - {0x0f, 2, 160}, + {0x0A, 2, 160}, + {0x0F, 2, 160}, {0x18, 2, 160}, - {0x1f, 2, 160}, + {0x1F, 2, 160}, {0x29, 2, 160}, {0x38, 3, 160}, {0x03, 2, 163}, {0x06, 2, 163}, - {0x0a, 2, 163}, - {0x0f, 2, 163}, + {0x0A, 2, 163}, + {0x0F, 2, 163}, {0x18, 2, 163}, - {0x1f, 2, 163}, + {0x1F, 2, 163}, {0x29, 2, 163}, {0x38, 3, 163}, }, @@ -2588,18 +2588,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 164}, {0x06, 2, 164}, - {0x0a, 2, 164}, - {0x0f, 2, 164}, + {0x0A, 2, 164}, + {0x0F, 2, 164}, {0x18, 2, 164}, - {0x1f, 2, 164}, + {0x1F, 2, 164}, {0x29, 2, 164}, {0x38, 3, 164}, {0x03, 2, 169}, {0x06, 2, 169}, - {0x0a, 2, 169}, - {0x0f, 2, 169}, + {0x0A, 2, 169}, + {0x0F, 2, 169}, {0x18, 2, 169}, - {0x1f, 2, 169}, + {0x1F, 2, 169}, {0x29, 2, 169}, {0x38, 3, 169}, }, @@ -2607,39 +2607,39 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 170}, {0x06, 2, 170}, - {0x0a, 2, 170}, - {0x0f, 2, 170}, + {0x0A, 2, 170}, + {0x0F, 2, 170}, {0x18, 2, 170}, - {0x1f, 2, 170}, + {0x1F, 2, 170}, {0x29, 2, 170}, {0x38, 3, 170}, {0x03, 2, 173}, {0x06, 2, 173}, - {0x0a, 2, 173}, - {0x0f, 2, 173}, + {0x0A, 2, 173}, + {0x0F, 2, 173}, {0x18, 2, 173}, - {0x1f, 2, 173}, + {0x1F, 2, 173}, {0x29, 2, 173}, {0x38, 3, 173}, }, /* 133 */ { {0x89, 0, 0}, - {0x8a, 0, 0}, - {0x8c, 0, 0}, - {0x8d, 0, 0}, + {0x8A, 0, 0}, + {0x8C, 0, 0}, + {0x8D, 0, 0}, {0x90, 0, 0}, {0x91, 0, 0}, {0x93, 0, 0}, {0x96, 0, 0}, - {0x9c, 0, 0}, - {0x9f, 0, 0}, - {0xa3, 0, 0}, - {0xa6, 0, 0}, - {0xab, 0, 0}, - {0xae, 0, 0}, - {0xb5, 0, 0}, - {0xbe, 0, 0}, + {0x9C, 0, 0}, + {0x9F, 0, 0}, + {0xA3, 0, 0}, + {0xA6, 0, 0}, + {0xAB, 0, 0}, + {0xAE, 0, 0}, + {0xB5, 0, 0}, + {0xBE, 0, 0}, }, /* 134 */ { @@ -2702,18 +2702,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 178}, {0x06, 2, 178}, - {0x0a, 2, 178}, - {0x0f, 2, 178}, + {0x0A, 2, 178}, + {0x0F, 2, 178}, {0x18, 2, 178}, - {0x1f, 2, 178}, + {0x1F, 2, 178}, {0x29, 2, 178}, {0x38, 3, 178}, {0x03, 2, 181}, {0x06, 2, 181}, - {0x0a, 2, 181}, - {0x0f, 2, 181}, + {0x0A, 2, 181}, + {0x0F, 2, 181}, {0x18, 2, 181}, - {0x1f, 2, 181}, + {0x1F, 2, 181}, {0x29, 2, 181}, {0x38, 3, 181}, }, @@ -2721,18 +2721,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 185}, {0x06, 2, 185}, - {0x0a, 2, 185}, - {0x0f, 2, 185}, + {0x0A, 2, 185}, + {0x0F, 2, 185}, {0x18, 2, 185}, - {0x1f, 2, 185}, + {0x1F, 2, 185}, {0x29, 2, 185}, {0x38, 3, 185}, {0x03, 2, 186}, {0x06, 2, 186}, - {0x0a, 2, 186}, - {0x0f, 2, 186}, + {0x0A, 2, 186}, + {0x0F, 2, 186}, {0x18, 2, 186}, - {0x1f, 2, 186}, + {0x1F, 2, 186}, {0x29, 2, 186}, {0x38, 3, 186}, }, @@ -2759,18 +2759,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 187}, {0x06, 2, 187}, - {0x0a, 2, 187}, - {0x0f, 2, 187}, + {0x0A, 2, 187}, + {0x0F, 2, 187}, {0x18, 2, 187}, - {0x1f, 2, 187}, + {0x1F, 2, 187}, {0x29, 2, 187}, {0x38, 3, 187}, {0x03, 2, 189}, {0x06, 2, 189}, - {0x0a, 2, 189}, - {0x0f, 2, 189}, + {0x0A, 2, 189}, + {0x0F, 2, 189}, {0x18, 2, 189}, - {0x1f, 2, 189}, + {0x1F, 2, 189}, {0x29, 2, 189}, {0x38, 3, 189}, }, @@ -2778,18 +2778,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 190}, {0x06, 2, 190}, - {0x0a, 2, 190}, - {0x0f, 2, 190}, + {0x0A, 2, 190}, + {0x0F, 2, 190}, {0x18, 2, 190}, - {0x1f, 2, 190}, + {0x1F, 2, 190}, {0x29, 2, 190}, {0x38, 3, 190}, {0x03, 2, 196}, {0x06, 2, 196}, - {0x0a, 2, 196}, - {0x0f, 2, 196}, + {0x0A, 2, 196}, + {0x0F, 2, 196}, {0x18, 2, 196}, - {0x1f, 2, 196}, + {0x1F, 2, 196}, {0x29, 2, 196}, {0x38, 3, 196}, }, @@ -2835,18 +2835,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 198}, {0x06, 2, 198}, - {0x0a, 2, 198}, - {0x0f, 2, 198}, + {0x0A, 2, 198}, + {0x0F, 2, 198}, {0x18, 2, 198}, - {0x1f, 2, 198}, + {0x1F, 2, 198}, {0x29, 2, 198}, {0x38, 3, 198}, {0x03, 2, 228}, {0x06, 2, 228}, - {0x0a, 2, 228}, - {0x0f, 2, 228}, + {0x0A, 2, 228}, + {0x0F, 2, 228}, {0x18, 2, 228}, - {0x1f, 2, 228}, + {0x1F, 2, 228}, {0x29, 2, 228}, {0x38, 3, 228}, }, @@ -2854,18 +2854,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 232}, {0x06, 2, 232}, - {0x0a, 2, 232}, - {0x0f, 2, 232}, + {0x0A, 2, 232}, + {0x0F, 2, 232}, {0x18, 2, 232}, - {0x1f, 2, 232}, + {0x1F, 2, 232}, {0x29, 2, 232}, {0x38, 3, 232}, {0x03, 2, 233}, {0x06, 2, 233}, - {0x0a, 2, 233}, - {0x0f, 2, 233}, + {0x0A, 2, 233}, + {0x0F, 2, 233}, {0x18, 2, 233}, - {0x1f, 2, 233}, + {0x1F, 2, 233}, {0x29, 2, 233}, {0x38, 3, 233}, }, @@ -2911,18 +2911,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 1}, {0x06, 2, 1}, - {0x0a, 2, 1}, - {0x0f, 2, 1}, + {0x0A, 2, 1}, + {0x0F, 2, 1}, {0x18, 2, 1}, - {0x1f, 2, 1}, + {0x1F, 2, 1}, {0x29, 2, 1}, {0x38, 3, 1}, {0x03, 2, 135}, {0x06, 2, 135}, - {0x0a, 2, 135}, - {0x0f, 2, 135}, + {0x0A, 2, 135}, + {0x0F, 2, 135}, {0x18, 2, 135}, - {0x1f, 2, 135}, + {0x1F, 2, 135}, {0x29, 2, 135}, {0x38, 3, 135}, }, @@ -2930,18 +2930,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 137}, {0x06, 2, 137}, - {0x0a, 2, 137}, - {0x0f, 2, 137}, + {0x0A, 2, 137}, + {0x0F, 2, 137}, {0x18, 2, 137}, - {0x1f, 2, 137}, + {0x1F, 2, 137}, {0x29, 2, 137}, {0x38, 3, 137}, {0x03, 2, 138}, {0x06, 2, 138}, - {0x0a, 2, 138}, - {0x0f, 2, 138}, + {0x0A, 2, 138}, + {0x0F, 2, 138}, {0x18, 2, 138}, - {0x1f, 2, 138}, + {0x1F, 2, 138}, {0x29, 2, 138}, {0x38, 3, 138}, }, @@ -2968,18 +2968,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 139}, {0x06, 2, 139}, - {0x0a, 2, 139}, - {0x0f, 2, 139}, + {0x0A, 2, 139}, + {0x0F, 2, 139}, {0x18, 2, 139}, - {0x1f, 2, 139}, + {0x1F, 2, 139}, {0x29, 2, 139}, {0x38, 3, 139}, {0x03, 2, 140}, {0x06, 2, 140}, - {0x0a, 2, 140}, - {0x0f, 2, 140}, + {0x0A, 2, 140}, + {0x0F, 2, 140}, {0x18, 2, 140}, - {0x1f, 2, 140}, + {0x1F, 2, 140}, {0x29, 2, 140}, {0x38, 3, 140}, }, @@ -2987,39 +2987,39 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 141}, {0x06, 2, 141}, - {0x0a, 2, 141}, - {0x0f, 2, 141}, + {0x0A, 2, 141}, + {0x0F, 2, 141}, {0x18, 2, 141}, - {0x1f, 2, 141}, + {0x1F, 2, 141}, {0x29, 2, 141}, {0x38, 3, 141}, {0x03, 2, 143}, {0x06, 2, 143}, - {0x0a, 2, 143}, - {0x0f, 2, 143}, + {0x0A, 2, 143}, + {0x0F, 2, 143}, {0x18, 2, 143}, - {0x1f, 2, 143}, + {0x1F, 2, 143}, {0x29, 2, 143}, {0x38, 3, 143}, }, /* 153 */ { - {0x9d, 0, 0}, - {0x9e, 0, 0}, - {0xa0, 0, 0}, - {0xa1, 0, 0}, - {0xa4, 0, 0}, - {0xa5, 0, 0}, - {0xa7, 0, 0}, - {0xa8, 0, 0}, - {0xac, 0, 0}, - {0xad, 0, 0}, - {0xaf, 0, 0}, - {0xb1, 0, 0}, - {0xb6, 0, 0}, - {0xb9, 0, 0}, - {0xbf, 0, 0}, - {0xcf, 0, 0}, + {0x9D, 0, 0}, + {0x9E, 0, 0}, + {0xA0, 0, 0}, + {0xA1, 0, 0}, + {0xA4, 0, 0}, + {0xA5, 0, 0}, + {0xA7, 0, 0}, + {0xA8, 0, 0}, + {0xAC, 0, 0}, + {0xAD, 0, 0}, + {0xAF, 0, 0}, + {0xB1, 0, 0}, + {0xB6, 0, 0}, + {0xB9, 0, 0}, + {0xBF, 0, 0}, + {0xCF, 0, 0}, }, /* 154 */ { @@ -3082,18 +3082,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 147}, {0x06, 2, 147}, - {0x0a, 2, 147}, - {0x0f, 2, 147}, + {0x0A, 2, 147}, + {0x0F, 2, 147}, {0x18, 2, 147}, - {0x1f, 2, 147}, + {0x1F, 2, 147}, {0x29, 2, 147}, {0x38, 3, 147}, {0x03, 2, 149}, {0x06, 2, 149}, - {0x0a, 2, 149}, - {0x0f, 2, 149}, + {0x0A, 2, 149}, + {0x0F, 2, 149}, {0x18, 2, 149}, - {0x1f, 2, 149}, + {0x1F, 2, 149}, {0x29, 2, 149}, {0x38, 3, 149}, }, @@ -3101,18 +3101,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 150}, {0x06, 2, 150}, - {0x0a, 2, 150}, - {0x0f, 2, 150}, + {0x0A, 2, 150}, + {0x0F, 2, 150}, {0x18, 2, 150}, - {0x1f, 2, 150}, + {0x1F, 2, 150}, {0x29, 2, 150}, {0x38, 3, 150}, {0x03, 2, 151}, {0x06, 2, 151}, - {0x0a, 2, 151}, - {0x0f, 2, 151}, + {0x0A, 2, 151}, + {0x0F, 2, 151}, {0x18, 2, 151}, - {0x1f, 2, 151}, + {0x1F, 2, 151}, {0x29, 2, 151}, {0x38, 3, 151}, }, @@ -3139,18 +3139,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 152}, {0x06, 2, 152}, - {0x0a, 2, 152}, - {0x0f, 2, 152}, + {0x0A, 2, 152}, + {0x0F, 2, 152}, {0x18, 2, 152}, - {0x1f, 2, 152}, + {0x1F, 2, 152}, {0x29, 2, 152}, {0x38, 3, 152}, {0x03, 2, 155}, {0x06, 2, 155}, - {0x0a, 2, 155}, - {0x0f, 2, 155}, + {0x0A, 2, 155}, + {0x0F, 2, 155}, {0x18, 2, 155}, - {0x1f, 2, 155}, + {0x1F, 2, 155}, {0x29, 2, 155}, {0x38, 3, 155}, }, @@ -3158,18 +3158,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 157}, {0x06, 2, 157}, - {0x0a, 2, 157}, - {0x0f, 2, 157}, + {0x0A, 2, 157}, + {0x0F, 2, 157}, {0x18, 2, 157}, - {0x1f, 2, 157}, + {0x1F, 2, 157}, {0x29, 2, 157}, {0x38, 3, 157}, {0x03, 2, 158}, {0x06, 2, 158}, - {0x0a, 2, 158}, - {0x0f, 2, 158}, + {0x0A, 2, 158}, + {0x0F, 2, 158}, {0x18, 2, 158}, - {0x1f, 2, 158}, + {0x1F, 2, 158}, {0x29, 2, 158}, {0x38, 3, 158}, }, @@ -3215,18 +3215,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 165}, {0x06, 2, 165}, - {0x0a, 2, 165}, - {0x0f, 2, 165}, + {0x0A, 2, 165}, + {0x0F, 2, 165}, {0x18, 2, 165}, - {0x1f, 2, 165}, + {0x1F, 2, 165}, {0x29, 2, 165}, {0x38, 3, 165}, {0x03, 2, 166}, {0x06, 2, 166}, - {0x0a, 2, 166}, - {0x0f, 2, 166}, + {0x0A, 2, 166}, + {0x0F, 2, 166}, {0x18, 2, 166}, - {0x1f, 2, 166}, + {0x1F, 2, 166}, {0x29, 2, 166}, {0x38, 3, 166}, }, @@ -3234,18 +3234,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 168}, {0x06, 2, 168}, - {0x0a, 2, 168}, - {0x0f, 2, 168}, + {0x0A, 2, 168}, + {0x0F, 2, 168}, {0x18, 2, 168}, - {0x1f, 2, 168}, + {0x1F, 2, 168}, {0x29, 2, 168}, {0x38, 3, 168}, {0x03, 2, 174}, {0x06, 2, 174}, - {0x0a, 2, 174}, - {0x0f, 2, 174}, + {0x0A, 2, 174}, + {0x0F, 2, 174}, {0x18, 2, 174}, - {0x1f, 2, 174}, + {0x1F, 2, 174}, {0x29, 2, 174}, {0x38, 3, 174}, }, @@ -3272,18 +3272,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 175}, {0x06, 2, 175}, - {0x0a, 2, 175}, - {0x0f, 2, 175}, + {0x0A, 2, 175}, + {0x0F, 2, 175}, {0x18, 2, 175}, - {0x1f, 2, 175}, + {0x1F, 2, 175}, {0x29, 2, 175}, {0x38, 3, 175}, {0x03, 2, 180}, {0x06, 2, 180}, - {0x0a, 2, 180}, - {0x0f, 2, 180}, + {0x0A, 2, 180}, + {0x0F, 2, 180}, {0x18, 2, 180}, - {0x1f, 2, 180}, + {0x1F, 2, 180}, {0x29, 2, 180}, {0x38, 3, 180}, }, @@ -3291,18 +3291,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 182}, {0x06, 2, 182}, - {0x0a, 2, 182}, - {0x0f, 2, 182}, + {0x0A, 2, 182}, + {0x0F, 2, 182}, {0x18, 2, 182}, - {0x1f, 2, 182}, + {0x1F, 2, 182}, {0x29, 2, 182}, {0x38, 3, 182}, {0x03, 2, 183}, {0x06, 2, 183}, - {0x0a, 2, 183}, - {0x0f, 2, 183}, + {0x0A, 2, 183}, + {0x0F, 2, 183}, {0x18, 2, 183}, - {0x1f, 2, 183}, + {0x1F, 2, 183}, {0x29, 2, 183}, {0x38, 3, 183}, }, @@ -3313,17 +3313,17 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x00, 3, 197}, {0x00, 3, 231}, {0x00, 3, 239}, - {0xb0, 0, 0}, - {0xb2, 0, 0}, - {0xb3, 0, 0}, - {0xb7, 0, 0}, - {0xb8, 0, 0}, - {0xba, 0, 0}, - {0xbb, 0, 0}, - {0xc0, 0, 0}, - {0xc7, 0, 0}, - {0xd0, 0, 0}, - {0xdf, 0, 0}, + {0xB0, 0, 0}, + {0xB2, 0, 0}, + {0xB3, 0, 0}, + {0xB7, 0, 0}, + {0xB8, 0, 0}, + {0xBA, 0, 0}, + {0xBB, 0, 0}, + {0xC0, 0, 0}, + {0xC7, 0, 0}, + {0xD0, 0, 0}, + {0xDF, 0, 0}, }, /* 170 */ { @@ -3367,18 +3367,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 188}, {0x06, 2, 188}, - {0x0a, 2, 188}, - {0x0f, 2, 188}, + {0x0A, 2, 188}, + {0x0F, 2, 188}, {0x18, 2, 188}, - {0x1f, 2, 188}, + {0x1F, 2, 188}, {0x29, 2, 188}, {0x38, 3, 188}, {0x03, 2, 191}, {0x06, 2, 191}, - {0x0a, 2, 191}, - {0x0f, 2, 191}, + {0x0A, 2, 191}, + {0x0F, 2, 191}, {0x18, 2, 191}, - {0x1f, 2, 191}, + {0x1F, 2, 191}, {0x29, 2, 191}, {0x38, 3, 191}, }, @@ -3386,18 +3386,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 197}, {0x06, 2, 197}, - {0x0a, 2, 197}, - {0x0f, 2, 197}, + {0x0A, 2, 197}, + {0x0F, 2, 197}, {0x18, 2, 197}, - {0x1f, 2, 197}, + {0x1F, 2, 197}, {0x29, 2, 197}, {0x38, 3, 197}, {0x03, 2, 231}, {0x06, 2, 231}, - {0x0a, 2, 231}, - {0x0f, 2, 231}, + {0x0A, 2, 231}, + {0x0F, 2, 231}, {0x18, 2, 231}, - {0x1f, 2, 231}, + {0x1F, 2, 231}, {0x29, 2, 231}, {0x38, 3, 231}, }, @@ -3424,10 +3424,10 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 239}, {0x06, 2, 239}, - {0x0a, 2, 239}, - {0x0f, 2, 239}, + {0x0A, 2, 239}, + {0x0F, 2, 239}, {0x18, 2, 239}, - {0x1f, 2, 239}, + {0x1F, 2, 239}, {0x29, 2, 239}, {0x38, 3, 239}, {0x02, 2, 9}, @@ -3443,18 +3443,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 9}, {0x06, 2, 9}, - {0x0a, 2, 9}, - {0x0f, 2, 9}, + {0x0A, 2, 9}, + {0x0F, 2, 9}, {0x18, 2, 9}, - {0x1f, 2, 9}, + {0x1F, 2, 9}, {0x29, 2, 9}, {0x38, 3, 9}, {0x03, 2, 142}, {0x06, 2, 142}, - {0x0a, 2, 142}, - {0x0f, 2, 142}, + {0x0A, 2, 142}, + {0x0F, 2, 142}, {0x18, 2, 142}, - {0x1f, 2, 142}, + {0x1F, 2, 142}, {0x29, 2, 142}, {0x38, 3, 142}, }, @@ -3481,18 +3481,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 144}, {0x06, 2, 144}, - {0x0a, 2, 144}, - {0x0f, 2, 144}, + {0x0A, 2, 144}, + {0x0F, 2, 144}, {0x18, 2, 144}, - {0x1f, 2, 144}, + {0x1F, 2, 144}, {0x29, 2, 144}, {0x38, 3, 144}, {0x03, 2, 145}, {0x06, 2, 145}, - {0x0a, 2, 145}, - {0x0f, 2, 145}, + {0x0A, 2, 145}, + {0x0F, 2, 145}, {0x18, 2, 145}, - {0x1f, 2, 145}, + {0x1F, 2, 145}, {0x29, 2, 145}, {0x38, 3, 145}, }, @@ -3500,18 +3500,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 148}, {0x06, 2, 148}, - {0x0a, 2, 148}, - {0x0f, 2, 148}, + {0x0A, 2, 148}, + {0x0F, 2, 148}, {0x18, 2, 148}, - {0x1f, 2, 148}, + {0x1F, 2, 148}, {0x29, 2, 148}, {0x38, 3, 148}, {0x03, 2, 159}, {0x06, 2, 159}, - {0x0a, 2, 159}, - {0x0f, 2, 159}, + {0x0A, 2, 159}, + {0x0F, 2, 159}, {0x18, 2, 159}, - {0x1f, 2, 159}, + {0x1F, 2, 159}, {0x29, 2, 159}, {0x38, 3, 159}, }, @@ -3523,16 +3523,16 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x00, 3, 225}, {0x00, 3, 236}, {0x00, 3, 237}, - {0xbc, 0, 0}, - {0xbd, 0, 0}, - {0xc1, 0, 0}, - {0xc4, 0, 0}, - {0xc8, 0, 0}, - {0xcb, 0, 0}, - {0xd1, 0, 0}, - {0xd8, 0, 0}, - {0xe0, 0, 0}, - {0xee, 0, 0}, + {0xBC, 0, 0}, + {0xBD, 0, 0}, + {0xC1, 0, 0}, + {0xC4, 0, 0}, + {0xC8, 0, 0}, + {0xCB, 0, 0}, + {0xD1, 0, 0}, + {0xD8, 0, 0}, + {0xE0, 0, 0}, + {0xEE, 0, 0}, }, /* 181 */ { @@ -3576,18 +3576,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 171}, {0x06, 2, 171}, - {0x0a, 2, 171}, - {0x0f, 2, 171}, + {0x0A, 2, 171}, + {0x0F, 2, 171}, {0x18, 2, 171}, - {0x1f, 2, 171}, + {0x1F, 2, 171}, {0x29, 2, 171}, {0x38, 3, 171}, {0x03, 2, 206}, {0x06, 2, 206}, - {0x0a, 2, 206}, - {0x0f, 2, 206}, + {0x0A, 2, 206}, + {0x0F, 2, 206}, {0x18, 2, 206}, - {0x1f, 2, 206}, + {0x1F, 2, 206}, {0x29, 2, 206}, {0x38, 3, 206}, }, @@ -3595,18 +3595,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 215}, {0x06, 2, 215}, - {0x0a, 2, 215}, - {0x0f, 2, 215}, + {0x0A, 2, 215}, + {0x0F, 2, 215}, {0x18, 2, 215}, - {0x1f, 2, 215}, + {0x1F, 2, 215}, {0x29, 2, 215}, {0x38, 3, 215}, {0x03, 2, 225}, {0x06, 2, 225}, - {0x0a, 2, 225}, - {0x0f, 2, 225}, + {0x0A, 2, 225}, + {0x0F, 2, 225}, {0x18, 2, 225}, - {0x1f, 2, 225}, + {0x1F, 2, 225}, {0x29, 2, 225}, {0x38, 3, 225}, }, @@ -3633,18 +3633,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 236}, {0x06, 2, 236}, - {0x0a, 2, 236}, - {0x0f, 2, 236}, + {0x0A, 2, 236}, + {0x0F, 2, 236}, {0x18, 2, 236}, - {0x1f, 2, 236}, + {0x1F, 2, 236}, {0x29, 2, 236}, {0x38, 3, 236}, {0x03, 2, 237}, {0x06, 2, 237}, - {0x0a, 2, 237}, - {0x0f, 2, 237}, + {0x0A, 2, 237}, + {0x0F, 2, 237}, {0x18, 2, 237}, - {0x1f, 2, 237}, + {0x1F, 2, 237}, {0x29, 2, 237}, {0x38, 3, 237}, }, @@ -3671,18 +3671,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 199}, {0x06, 2, 199}, - {0x0a, 2, 199}, - {0x0f, 2, 199}, + {0x0A, 2, 199}, + {0x0F, 2, 199}, {0x18, 2, 199}, - {0x1f, 2, 199}, + {0x1F, 2, 199}, {0x29, 2, 199}, {0x38, 3, 199}, {0x03, 2, 207}, {0x06, 2, 207}, - {0x0a, 2, 207}, - {0x0f, 2, 207}, + {0x0A, 2, 207}, + {0x0F, 2, 207}, {0x18, 2, 207}, - {0x1f, 2, 207}, + {0x1F, 2, 207}, {0x29, 2, 207}, {0x38, 3, 207}, }, @@ -3690,39 +3690,39 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 234}, {0x06, 2, 234}, - {0x0a, 2, 234}, - {0x0f, 2, 234}, + {0x0A, 2, 234}, + {0x0F, 2, 234}, {0x18, 2, 234}, - {0x1f, 2, 234}, + {0x1F, 2, 234}, {0x29, 2, 234}, {0x38, 3, 234}, {0x03, 2, 235}, {0x06, 2, 235}, - {0x0a, 2, 235}, - {0x0f, 2, 235}, + {0x0A, 2, 235}, + {0x0F, 2, 235}, {0x18, 2, 235}, - {0x1f, 2, 235}, + {0x1F, 2, 235}, {0x29, 2, 235}, {0x38, 3, 235}, }, /* 190 */ { - {0xc2, 0, 0}, - {0xc3, 0, 0}, - {0xc5, 0, 0}, - {0xc6, 0, 0}, - {0xc9, 0, 0}, - {0xca, 0, 0}, - {0xcc, 0, 0}, - {0xcd, 0, 0}, - {0xd2, 0, 0}, - {0xd5, 0, 0}, - {0xd9, 0, 0}, - {0xdc, 0, 0}, - {0xe1, 0, 0}, - {0xe7, 0, 0}, - {0xef, 0, 0}, - {0xf6, 0, 0}, + {0xC2, 0, 0}, + {0xC3, 0, 0}, + {0xC5, 0, 0}, + {0xC6, 0, 0}, + {0xC9, 0, 0}, + {0xCA, 0, 0}, + {0xCC, 0, 0}, + {0xCD, 0, 0}, + {0xD2, 0, 0}, + {0xD5, 0, 0}, + {0xD9, 0, 0}, + {0xDC, 0, 0}, + {0xE1, 0, 0}, + {0xE7, 0, 0}, + {0xEF, 0, 0}, + {0xF6, 0, 0}, }, /* 191 */ { @@ -3741,7 +3741,7 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x00, 3, 242}, {0x00, 3, 243}, {0x00, 3, 255}, - {0xce, 0, 0}, + {0xCE, 0, 0}, }, /* 192 */ { @@ -3785,18 +3785,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 192}, {0x06, 2, 192}, - {0x0a, 2, 192}, - {0x0f, 2, 192}, + {0x0A, 2, 192}, + {0x0F, 2, 192}, {0x18, 2, 192}, - {0x1f, 2, 192}, + {0x1F, 2, 192}, {0x29, 2, 192}, {0x38, 3, 192}, {0x03, 2, 193}, {0x06, 2, 193}, - {0x0a, 2, 193}, - {0x0f, 2, 193}, + {0x0A, 2, 193}, + {0x0F, 2, 193}, {0x18, 2, 193}, - {0x1f, 2, 193}, + {0x1F, 2, 193}, {0x29, 2, 193}, {0x38, 3, 193}, }, @@ -3804,18 +3804,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 200}, {0x06, 2, 200}, - {0x0a, 2, 200}, - {0x0f, 2, 200}, + {0x0A, 2, 200}, + {0x0F, 2, 200}, {0x18, 2, 200}, - {0x1f, 2, 200}, + {0x1F, 2, 200}, {0x29, 2, 200}, {0x38, 3, 200}, {0x03, 2, 201}, {0x06, 2, 201}, - {0x0a, 2, 201}, - {0x0f, 2, 201}, + {0x0A, 2, 201}, + {0x0F, 2, 201}, {0x18, 2, 201}, - {0x1f, 2, 201}, + {0x1F, 2, 201}, {0x29, 2, 201}, {0x38, 3, 201}, }, @@ -3842,18 +3842,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 202}, {0x06, 2, 202}, - {0x0a, 2, 202}, - {0x0f, 2, 202}, + {0x0A, 2, 202}, + {0x0F, 2, 202}, {0x18, 2, 202}, - {0x1f, 2, 202}, + {0x1F, 2, 202}, {0x29, 2, 202}, {0x38, 3, 202}, {0x03, 2, 205}, {0x06, 2, 205}, - {0x0a, 2, 205}, - {0x0f, 2, 205}, + {0x0A, 2, 205}, + {0x0F, 2, 205}, {0x18, 2, 205}, - {0x1f, 2, 205}, + {0x1F, 2, 205}, {0x29, 2, 205}, {0x38, 3, 205}, }, @@ -3861,18 +3861,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 210}, {0x06, 2, 210}, - {0x0a, 2, 210}, - {0x0f, 2, 210}, + {0x0A, 2, 210}, + {0x0F, 2, 210}, {0x18, 2, 210}, - {0x1f, 2, 210}, + {0x1F, 2, 210}, {0x29, 2, 210}, {0x38, 3, 210}, {0x03, 2, 213}, {0x06, 2, 213}, - {0x0a, 2, 213}, - {0x0f, 2, 213}, + {0x0A, 2, 213}, + {0x0F, 2, 213}, {0x18, 2, 213}, - {0x1f, 2, 213}, + {0x1F, 2, 213}, {0x29, 2, 213}, {0x38, 3, 213}, }, @@ -3918,18 +3918,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 218}, {0x06, 2, 218}, - {0x0a, 2, 218}, - {0x0f, 2, 218}, + {0x0A, 2, 218}, + {0x0F, 2, 218}, {0x18, 2, 218}, - {0x1f, 2, 218}, + {0x1F, 2, 218}, {0x29, 2, 218}, {0x38, 3, 218}, {0x03, 2, 219}, {0x06, 2, 219}, - {0x0a, 2, 219}, - {0x0f, 2, 219}, + {0x0A, 2, 219}, + {0x0F, 2, 219}, {0x18, 2, 219}, - {0x1f, 2, 219}, + {0x1F, 2, 219}, {0x29, 2, 219}, {0x38, 3, 219}, }, @@ -3937,18 +3937,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 238}, {0x06, 2, 238}, - {0x0a, 2, 238}, - {0x0f, 2, 238}, + {0x0A, 2, 238}, + {0x0F, 2, 238}, {0x18, 2, 238}, - {0x1f, 2, 238}, + {0x1F, 2, 238}, {0x29, 2, 238}, {0x38, 3, 238}, {0x03, 2, 240}, {0x06, 2, 240}, - {0x0a, 2, 240}, - {0x0f, 2, 240}, + {0x0A, 2, 240}, + {0x0F, 2, 240}, {0x18, 2, 240}, - {0x1f, 2, 240}, + {0x1F, 2, 240}, {0x29, 2, 240}, {0x38, 3, 240}, }, @@ -3975,18 +3975,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 242}, {0x06, 2, 242}, - {0x0a, 2, 242}, - {0x0f, 2, 242}, + {0x0A, 2, 242}, + {0x0F, 2, 242}, {0x18, 2, 242}, - {0x1f, 2, 242}, + {0x1F, 2, 242}, {0x29, 2, 242}, {0x38, 3, 242}, {0x03, 2, 243}, {0x06, 2, 243}, - {0x0a, 2, 243}, - {0x0f, 2, 243}, + {0x0A, 2, 243}, + {0x0F, 2, 243}, {0x18, 2, 243}, - {0x1f, 2, 243}, + {0x1F, 2, 243}, {0x29, 2, 243}, {0x38, 3, 243}, }, @@ -3994,10 +3994,10 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 255}, {0x06, 2, 255}, - {0x0a, 2, 255}, - {0x0f, 2, 255}, + {0x0A, 2, 255}, + {0x0F, 2, 255}, {0x18, 2, 255}, - {0x1f, 2, 255}, + {0x1F, 2, 255}, {0x29, 2, 255}, {0x38, 3, 255}, {0x02, 2, 203}, @@ -4013,39 +4013,39 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 203}, {0x06, 2, 203}, - {0x0a, 2, 203}, - {0x0f, 2, 203}, + {0x0A, 2, 203}, + {0x0F, 2, 203}, {0x18, 2, 203}, - {0x1f, 2, 203}, + {0x1F, 2, 203}, {0x29, 2, 203}, {0x38, 3, 203}, {0x03, 2, 204}, {0x06, 2, 204}, - {0x0a, 2, 204}, - {0x0f, 2, 204}, + {0x0A, 2, 204}, + {0x0F, 2, 204}, {0x18, 2, 204}, - {0x1f, 2, 204}, + {0x1F, 2, 204}, {0x29, 2, 204}, {0x38, 3, 204}, }, /* 207 */ { - {0xd3, 0, 0}, - {0xd4, 0, 0}, - {0xd6, 0, 0}, - {0xd7, 0, 0}, - {0xda, 0, 0}, - {0xdb, 0, 0}, - {0xdd, 0, 0}, - {0xde, 0, 0}, - {0xe2, 0, 0}, - {0xe4, 0, 0}, - {0xe8, 0, 0}, - {0xeb, 0, 0}, - {0xf0, 0, 0}, - {0xf3, 0, 0}, - {0xf7, 0, 0}, - {0xfa, 0, 0}, + {0xD3, 0, 0}, + {0xD4, 0, 0}, + {0xD6, 0, 0}, + {0xD7, 0, 0}, + {0xDA, 0, 0}, + {0xDB, 0, 0}, + {0xDD, 0, 0}, + {0xDE, 0, 0}, + {0xE2, 0, 0}, + {0xE4, 0, 0}, + {0xE8, 0, 0}, + {0xEB, 0, 0}, + {0xF0, 0, 0}, + {0xF3, 0, 0}, + {0xF7, 0, 0}, + {0xFA, 0, 0}, }, /* 208 */ { @@ -4108,18 +4108,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 211}, {0x06, 2, 211}, - {0x0a, 2, 211}, - {0x0f, 2, 211}, + {0x0A, 2, 211}, + {0x0F, 2, 211}, {0x18, 2, 211}, - {0x1f, 2, 211}, + {0x1F, 2, 211}, {0x29, 2, 211}, {0x38, 3, 211}, {0x03, 2, 212}, {0x06, 2, 212}, - {0x0a, 2, 212}, - {0x0f, 2, 212}, + {0x0A, 2, 212}, + {0x0F, 2, 212}, {0x18, 2, 212}, - {0x1f, 2, 212}, + {0x1F, 2, 212}, {0x29, 2, 212}, {0x38, 3, 212}, }, @@ -4127,18 +4127,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 214}, {0x06, 2, 214}, - {0x0a, 2, 214}, - {0x0f, 2, 214}, + {0x0A, 2, 214}, + {0x0F, 2, 214}, {0x18, 2, 214}, - {0x1f, 2, 214}, + {0x1F, 2, 214}, {0x29, 2, 214}, {0x38, 3, 214}, {0x03, 2, 221}, {0x06, 2, 221}, - {0x0a, 2, 221}, - {0x0f, 2, 221}, + {0x0A, 2, 221}, + {0x0F, 2, 221}, {0x18, 2, 221}, - {0x1f, 2, 221}, + {0x1F, 2, 221}, {0x29, 2, 221}, {0x38, 3, 221}, }, @@ -4165,18 +4165,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 222}, {0x06, 2, 222}, - {0x0a, 2, 222}, - {0x0f, 2, 222}, + {0x0A, 2, 222}, + {0x0F, 2, 222}, {0x18, 2, 222}, - {0x1f, 2, 222}, + {0x1F, 2, 222}, {0x29, 2, 222}, {0x38, 3, 222}, {0x03, 2, 223}, {0x06, 2, 223}, - {0x0a, 2, 223}, - {0x0f, 2, 223}, + {0x0A, 2, 223}, + {0x0F, 2, 223}, {0x18, 2, 223}, - {0x1f, 2, 223}, + {0x1F, 2, 223}, {0x29, 2, 223}, {0x38, 3, 223}, }, @@ -4184,18 +4184,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 241}, {0x06, 2, 241}, - {0x0a, 2, 241}, - {0x0f, 2, 241}, + {0x0A, 2, 241}, + {0x0F, 2, 241}, {0x18, 2, 241}, - {0x1f, 2, 241}, + {0x1F, 2, 241}, {0x29, 2, 241}, {0x38, 3, 241}, {0x03, 2, 244}, {0x06, 2, 244}, - {0x0a, 2, 244}, - {0x0f, 2, 244}, + {0x0A, 2, 244}, + {0x0F, 2, 244}, {0x18, 2, 244}, - {0x1f, 2, 244}, + {0x1F, 2, 244}, {0x29, 2, 244}, {0x38, 3, 244}, }, @@ -4241,18 +4241,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 245}, {0x06, 2, 245}, - {0x0a, 2, 245}, - {0x0f, 2, 245}, + {0x0A, 2, 245}, + {0x0F, 2, 245}, {0x18, 2, 245}, - {0x1f, 2, 245}, + {0x1F, 2, 245}, {0x29, 2, 245}, {0x38, 3, 245}, {0x03, 2, 246}, {0x06, 2, 246}, - {0x0a, 2, 246}, - {0x0f, 2, 246}, + {0x0A, 2, 246}, + {0x0F, 2, 246}, {0x18, 2, 246}, - {0x1f, 2, 246}, + {0x1F, 2, 246}, {0x29, 2, 246}, {0x38, 3, 246}, }, @@ -4260,18 +4260,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 247}, {0x06, 2, 247}, - {0x0a, 2, 247}, - {0x0f, 2, 247}, + {0x0A, 2, 247}, + {0x0F, 2, 247}, {0x18, 2, 247}, - {0x1f, 2, 247}, + {0x1F, 2, 247}, {0x29, 2, 247}, {0x38, 3, 247}, {0x03, 2, 248}, {0x06, 2, 248}, - {0x0a, 2, 248}, - {0x0f, 2, 248}, + {0x0A, 2, 248}, + {0x0F, 2, 248}, {0x18, 2, 248}, - {0x1f, 2, 248}, + {0x1F, 2, 248}, {0x29, 2, 248}, {0x38, 3, 248}, }, @@ -4298,18 +4298,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 250}, {0x06, 2, 250}, - {0x0a, 2, 250}, - {0x0f, 2, 250}, + {0x0A, 2, 250}, + {0x0F, 2, 250}, {0x18, 2, 250}, - {0x1f, 2, 250}, + {0x1F, 2, 250}, {0x29, 2, 250}, {0x38, 3, 250}, {0x03, 2, 251}, {0x06, 2, 251}, - {0x0a, 2, 251}, - {0x0f, 2, 251}, + {0x0A, 2, 251}, + {0x0F, 2, 251}, {0x18, 2, 251}, - {0x1f, 2, 251}, + {0x1F, 2, 251}, {0x29, 2, 251}, {0x38, 3, 251}, }, @@ -4317,39 +4317,39 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 252}, {0x06, 2, 252}, - {0x0a, 2, 252}, - {0x0f, 2, 252}, + {0x0A, 2, 252}, + {0x0F, 2, 252}, {0x18, 2, 252}, - {0x1f, 2, 252}, + {0x1F, 2, 252}, {0x29, 2, 252}, {0x38, 3, 252}, {0x03, 2, 253}, {0x06, 2, 253}, - {0x0a, 2, 253}, - {0x0f, 2, 253}, + {0x0A, 2, 253}, + {0x0F, 2, 253}, {0x18, 2, 253}, - {0x1f, 2, 253}, + {0x1F, 2, 253}, {0x29, 2, 253}, {0x38, 3, 253}, }, /* 223 */ { {0x00, 3, 254}, - {0xe3, 0, 0}, - {0xe5, 0, 0}, - {0xe6, 0, 0}, - {0xe9, 0, 0}, - {0xea, 0, 0}, - {0xec, 0, 0}, - {0xed, 0, 0}, - {0xf1, 0, 0}, - {0xf2, 0, 0}, - {0xf4, 0, 0}, - {0xf5, 0, 0}, - {0xf8, 0, 0}, - {0xf9, 0, 0}, - {0xfb, 0, 0}, - {0xfc, 0, 0}, + {0xE3, 0, 0}, + {0xE5, 0, 0}, + {0xE6, 0, 0}, + {0xE9, 0, 0}, + {0xEA, 0, 0}, + {0xEC, 0, 0}, + {0xED, 0, 0}, + {0xF1, 0, 0}, + {0xF2, 0, 0}, + {0xF4, 0, 0}, + {0xF5, 0, 0}, + {0xF8, 0, 0}, + {0xF9, 0, 0}, + {0xFB, 0, 0}, + {0xFC, 0, 0}, }, /* 224 */ { @@ -4393,10 +4393,10 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 254}, {0x06, 2, 254}, - {0x0a, 2, 254}, - {0x0f, 2, 254}, + {0x0A, 2, 254}, + {0x0F, 2, 254}, {0x18, 2, 254}, - {0x1f, 2, 254}, + {0x1F, 2, 254}, {0x29, 2, 254}, {0x38, 3, 254}, {0x02, 2, 2}, @@ -4412,18 +4412,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 2}, {0x06, 2, 2}, - {0x0a, 2, 2}, - {0x0f, 2, 2}, + {0x0A, 2, 2}, + {0x0F, 2, 2}, {0x18, 2, 2}, - {0x1f, 2, 2}, + {0x1F, 2, 2}, {0x29, 2, 2}, {0x38, 3, 2}, {0x03, 2, 3}, {0x06, 2, 3}, - {0x0a, 2, 3}, - {0x0f, 2, 3}, + {0x0A, 2, 3}, + {0x0F, 2, 3}, {0x18, 2, 3}, - {0x1f, 2, 3}, + {0x1F, 2, 3}, {0x29, 2, 3}, {0x38, 3, 3}, }, @@ -4450,18 +4450,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 4}, {0x06, 2, 4}, - {0x0a, 2, 4}, - {0x0f, 2, 4}, + {0x0A, 2, 4}, + {0x0F, 2, 4}, {0x18, 2, 4}, - {0x1f, 2, 4}, + {0x1F, 2, 4}, {0x29, 2, 4}, {0x38, 3, 4}, {0x03, 2, 5}, {0x06, 2, 5}, - {0x0a, 2, 5}, - {0x0f, 2, 5}, + {0x0A, 2, 5}, + {0x0F, 2, 5}, {0x18, 2, 5}, - {0x1f, 2, 5}, + {0x1F, 2, 5}, {0x29, 2, 5}, {0x38, 3, 5}, }, @@ -4469,18 +4469,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 6}, {0x06, 2, 6}, - {0x0a, 2, 6}, - {0x0f, 2, 6}, + {0x0A, 2, 6}, + {0x0F, 2, 6}, {0x18, 2, 6}, - {0x1f, 2, 6}, + {0x1F, 2, 6}, {0x29, 2, 6}, {0x38, 3, 6}, {0x03, 2, 7}, {0x06, 2, 7}, - {0x0a, 2, 7}, - {0x0f, 2, 7}, + {0x0A, 2, 7}, + {0x0F, 2, 7}, {0x18, 2, 7}, - {0x1f, 2, 7}, + {0x1F, 2, 7}, {0x29, 2, 7}, {0x38, 3, 7}, }, @@ -4526,18 +4526,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 8}, {0x06, 2, 8}, - {0x0a, 2, 8}, - {0x0f, 2, 8}, + {0x0A, 2, 8}, + {0x0F, 2, 8}, {0x18, 2, 8}, - {0x1f, 2, 8}, + {0x1F, 2, 8}, {0x29, 2, 8}, {0x38, 3, 8}, {0x03, 2, 11}, {0x06, 2, 11}, - {0x0a, 2, 11}, - {0x0f, 2, 11}, + {0x0A, 2, 11}, + {0x0F, 2, 11}, {0x18, 2, 11}, - {0x1f, 2, 11}, + {0x1F, 2, 11}, {0x29, 2, 11}, {0x38, 3, 11}, }, @@ -4545,18 +4545,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 12}, {0x06, 2, 12}, - {0x0a, 2, 12}, - {0x0f, 2, 12}, + {0x0A, 2, 12}, + {0x0F, 2, 12}, {0x18, 2, 12}, - {0x1f, 2, 12}, + {0x1F, 2, 12}, {0x29, 2, 12}, {0x38, 3, 12}, {0x03, 2, 14}, {0x06, 2, 14}, - {0x0a, 2, 14}, - {0x0f, 2, 14}, + {0x0A, 2, 14}, + {0x0F, 2, 14}, {0x18, 2, 14}, - {0x1f, 2, 14}, + {0x1F, 2, 14}, {0x29, 2, 14}, {0x38, 3, 14}, }, @@ -4583,18 +4583,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 15}, {0x06, 2, 15}, - {0x0a, 2, 15}, - {0x0f, 2, 15}, + {0x0A, 2, 15}, + {0x0F, 2, 15}, {0x18, 2, 15}, - {0x1f, 2, 15}, + {0x1F, 2, 15}, {0x29, 2, 15}, {0x38, 3, 15}, {0x03, 2, 16}, {0x06, 2, 16}, - {0x0a, 2, 16}, - {0x0f, 2, 16}, + {0x0A, 2, 16}, + {0x0F, 2, 16}, {0x18, 2, 16}, - {0x1f, 2, 16}, + {0x1F, 2, 16}, {0x29, 2, 16}, {0x38, 3, 16}, }, @@ -4602,18 +4602,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 17}, {0x06, 2, 17}, - {0x0a, 2, 17}, - {0x0f, 2, 17}, + {0x0A, 2, 17}, + {0x0F, 2, 17}, {0x18, 2, 17}, - {0x1f, 2, 17}, + {0x1F, 2, 17}, {0x29, 2, 17}, {0x38, 3, 17}, {0x03, 2, 18}, {0x06, 2, 18}, - {0x0a, 2, 18}, - {0x0f, 2, 18}, + {0x0A, 2, 18}, + {0x0F, 2, 18}, {0x18, 2, 18}, - {0x1f, 2, 18}, + {0x1F, 2, 18}, {0x29, 2, 18}, {0x38, 3, 18}, }, @@ -4634,7 +4634,7 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x00, 3, 127}, {0x00, 3, 220}, {0x00, 3, 249}, - {0xfd, 0, 0}, + {0xFD, 0, 0}, }, /* 239 */ { @@ -4678,18 +4678,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 19}, {0x06, 2, 19}, - {0x0a, 2, 19}, - {0x0f, 2, 19}, + {0x0A, 2, 19}, + {0x0F, 2, 19}, {0x18, 2, 19}, - {0x1f, 2, 19}, + {0x1F, 2, 19}, {0x29, 2, 19}, {0x38, 3, 19}, {0x03, 2, 20}, {0x06, 2, 20}, - {0x0a, 2, 20}, - {0x0f, 2, 20}, + {0x0A, 2, 20}, + {0x0F, 2, 20}, {0x18, 2, 20}, - {0x1f, 2, 20}, + {0x1F, 2, 20}, {0x29, 2, 20}, {0x38, 3, 20}, }, @@ -4697,18 +4697,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 21}, {0x06, 2, 21}, - {0x0a, 2, 21}, - {0x0f, 2, 21}, + {0x0A, 2, 21}, + {0x0F, 2, 21}, {0x18, 2, 21}, - {0x1f, 2, 21}, + {0x1F, 2, 21}, {0x29, 2, 21}, {0x38, 3, 21}, {0x03, 2, 23}, {0x06, 2, 23}, - {0x0a, 2, 23}, - {0x0f, 2, 23}, + {0x0A, 2, 23}, + {0x0F, 2, 23}, {0x18, 2, 23}, - {0x1f, 2, 23}, + {0x1F, 2, 23}, {0x29, 2, 23}, {0x38, 3, 23}, }, @@ -4735,18 +4735,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 24}, {0x06, 2, 24}, - {0x0a, 2, 24}, - {0x0f, 2, 24}, + {0x0A, 2, 24}, + {0x0F, 2, 24}, {0x18, 2, 24}, - {0x1f, 2, 24}, + {0x1F, 2, 24}, {0x29, 2, 24}, {0x38, 3, 24}, {0x03, 2, 25}, {0x06, 2, 25}, - {0x0a, 2, 25}, - {0x0f, 2, 25}, + {0x0A, 2, 25}, + {0x0F, 2, 25}, {0x18, 2, 25}, - {0x1f, 2, 25}, + {0x1F, 2, 25}, {0x29, 2, 25}, {0x38, 3, 25}, }, @@ -4754,18 +4754,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 26}, {0x06, 2, 26}, - {0x0a, 2, 26}, - {0x0f, 2, 26}, + {0x0A, 2, 26}, + {0x0F, 2, 26}, {0x18, 2, 26}, - {0x1f, 2, 26}, + {0x1F, 2, 26}, {0x29, 2, 26}, {0x38, 3, 26}, {0x03, 2, 27}, {0x06, 2, 27}, - {0x0a, 2, 27}, - {0x0f, 2, 27}, + {0x0A, 2, 27}, + {0x0F, 2, 27}, {0x18, 2, 27}, - {0x1f, 2, 27}, + {0x1F, 2, 27}, {0x29, 2, 27}, {0x38, 3, 27}, }, @@ -4785,8 +4785,8 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { {0x16, 3, 220}, {0x01, 2, 249}, {0x16, 3, 249}, - {0xfe, 0, 0}, - {0xff, 0, 0}, + {0xFE, 0, 0}, + {0xFF, 0, 0}, }, /* 247 */ { @@ -4811,18 +4811,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 28}, {0x06, 2, 28}, - {0x0a, 2, 28}, - {0x0f, 2, 28}, + {0x0A, 2, 28}, + {0x0F, 2, 28}, {0x18, 2, 28}, - {0x1f, 2, 28}, + {0x1F, 2, 28}, {0x29, 2, 28}, {0x38, 3, 28}, {0x03, 2, 29}, {0x06, 2, 29}, - {0x0a, 2, 29}, - {0x0f, 2, 29}, + {0x0A, 2, 29}, + {0x0F, 2, 29}, {0x18, 2, 29}, - {0x1f, 2, 29}, + {0x1F, 2, 29}, {0x29, 2, 29}, {0x38, 3, 29}, }, @@ -4830,18 +4830,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 30}, {0x06, 2, 30}, - {0x0a, 2, 30}, - {0x0f, 2, 30}, + {0x0A, 2, 30}, + {0x0F, 2, 30}, {0x18, 2, 30}, - {0x1f, 2, 30}, + {0x1F, 2, 30}, {0x29, 2, 30}, {0x38, 3, 30}, {0x03, 2, 31}, {0x06, 2, 31}, - {0x0a, 2, 31}, - {0x0f, 2, 31}, + {0x0A, 2, 31}, + {0x0F, 2, 31}, {0x18, 2, 31}, - {0x1f, 2, 31}, + {0x1F, 2, 31}, {0x29, 2, 31}, {0x38, 3, 31}, }, @@ -4868,18 +4868,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 127}, {0x06, 2, 127}, - {0x0a, 2, 127}, - {0x0f, 2, 127}, + {0x0A, 2, 127}, + {0x0F, 2, 127}, {0x18, 2, 127}, - {0x1f, 2, 127}, + {0x1F, 2, 127}, {0x29, 2, 127}, {0x38, 3, 127}, {0x03, 2, 220}, {0x06, 2, 220}, - {0x0a, 2, 220}, - {0x0f, 2, 220}, + {0x0A, 2, 220}, + {0x0F, 2, 220}, {0x18, 2, 220}, - {0x1f, 2, 220}, + {0x1F, 2, 220}, {0x29, 2, 220}, {0x38, 3, 220}, }, @@ -4887,10 +4887,10 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 249}, {0x06, 2, 249}, - {0x0a, 2, 249}, - {0x0f, 2, 249}, + {0x0A, 2, 249}, + {0x0F, 2, 249}, {0x18, 2, 249}, - {0x1f, 2, 249}, + {0x1F, 2, 249}, {0x29, 2, 249}, {0x38, 3, 249}, {0x01, 2, 10}, @@ -4925,18 +4925,18 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 10}, {0x06, 2, 10}, - {0x0a, 2, 10}, - {0x0f, 2, 10}, + {0x0A, 2, 10}, + {0x0F, 2, 10}, {0x18, 2, 10}, - {0x1f, 2, 10}, + {0x1F, 2, 10}, {0x29, 2, 10}, {0x38, 3, 10}, {0x03, 2, 13}, {0x06, 2, 13}, - {0x0a, 2, 13}, - {0x0f, 2, 13}, + {0x0A, 2, 13}, + {0x0F, 2, 13}, {0x18, 2, 13}, - {0x1f, 2, 13}, + {0x1F, 2, 13}, {0x29, 2, 13}, {0x38, 3, 13}, }, @@ -4944,10 +4944,10 @@ const nghttp3_qpack_huffman_decode_node qpack_huffman_decode_table[][16] = { { {0x03, 2, 22}, {0x06, 2, 22}, - {0x0a, 2, 22}, - {0x0f, 2, 22}, + {0x0A, 2, 22}, + {0x0F, 2, 22}, {0x18, 2, 22}, - {0x1f, 2, 22}, + {0x1F, 2, 22}, {0x29, 2, 22}, {0x38, 3, 22}, {0x100, 0, 0}, diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_range.c b/deps/ngtcp2/nghttp3/lib/nghttp3_range.c index f3039d81c4e542..d54d9c3d7385e4 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_range.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_range.c @@ -36,8 +36,8 @@ void nghttp3_range_init(nghttp3_range *r, uint64_t begin, uint64_t end) { nghttp3_range nghttp3_range_intersect(const nghttp3_range *a, const nghttp3_range *b) { nghttp3_range r; - uint64_t begin = nghttp3_max_uint64(a->begin, b->begin); - uint64_t end = nghttp3_min_uint64(a->end, b->end); + uint64_t begin = nghttp3_max(a->begin, b->begin); + uint64_t end = nghttp3_min(a->end, b->end); if (begin < end) { nghttp3_range_init(&r, begin, end); diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c b/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c index dac89ef12e51c7..f43714d2c20d30 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c @@ -70,7 +70,7 @@ void nghttp3_ringbuf_free(nghttp3_ringbuf *rb) { void *nghttp3_ringbuf_push_front(nghttp3_ringbuf *rb) { rb->first = (rb->first - 1) & (rb->nmemb - 1); - rb->len = nghttp3_min_size(rb->nmemb, rb->len + 1); + rb->len = nghttp3_min(rb->nmemb, rb->len + 1); return (void *)&rb->buf[rb->first * rb->size]; } @@ -108,7 +108,9 @@ void *nghttp3_ringbuf_get(nghttp3_ringbuf *rb, size_t offset) { return &rb->buf[offset * rb->size]; } -int nghttp3_ringbuf_full(nghttp3_ringbuf *rb) { return rb->len == rb->nmemb; } +int nghttp3_ringbuf_full(const nghttp3_ringbuf *rb) { + return rb->len == rb->nmemb; +} int nghttp3_ringbuf_reserve(nghttp3_ringbuf *rb, size_t nmemb) { uint8_t *buf; diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.h b/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.h index 691c40b93d61e0..aae22aa8603f50 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.h @@ -108,7 +108,7 @@ static inline size_t nghttp3_ringbuf_len(const nghttp3_ringbuf *rb) { } /* nghttp3_ringbuf_full returns nonzero if |rb| is full. */ -int nghttp3_ringbuf_full(nghttp3_ringbuf *rb); +int nghttp3_ringbuf_full(const nghttp3_ringbuf *rb); int nghttp3_ringbuf_reserve(nghttp3_ringbuf *rb, size_t nmemb); diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_str.c b/deps/ngtcp2/nghttp3/lib/nghttp3_str.c index fc131404d13754..4fcda6658f8b55 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_str.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_str.c @@ -70,36 +70,36 @@ static const uint8_t DOWNCASE_TBL[] = { 124 /* | */, 125 /* } */, 126 /* ~ */, 127 /* DEL */, 128 /* 0x80 */, 129 /* 0x81 */, 130 /* 0x82 */, 131 /* 0x83 */, 132 /* 0x84 */, 133 /* 0x85 */, 134 /* 0x86 */, 135 /* 0x87 */, - 136 /* 0x88 */, 137 /* 0x89 */, 138 /* 0x8a */, 139 /* 0x8b */, - 140 /* 0x8c */, 141 /* 0x8d */, 142 /* 0x8e */, 143 /* 0x8f */, + 136 /* 0x88 */, 137 /* 0x89 */, 138 /* 0x8A */, 139 /* 0x8B */, + 140 /* 0x8C */, 141 /* 0x8D */, 142 /* 0x8E */, 143 /* 0x8F */, 144 /* 0x90 */, 145 /* 0x91 */, 146 /* 0x92 */, 147 /* 0x93 */, 148 /* 0x94 */, 149 /* 0x95 */, 150 /* 0x96 */, 151 /* 0x97 */, - 152 /* 0x98 */, 153 /* 0x99 */, 154 /* 0x9a */, 155 /* 0x9b */, - 156 /* 0x9c */, 157 /* 0x9d */, 158 /* 0x9e */, 159 /* 0x9f */, - 160 /* 0xa0 */, 161 /* 0xa1 */, 162 /* 0xa2 */, 163 /* 0xa3 */, - 164 /* 0xa4 */, 165 /* 0xa5 */, 166 /* 0xa6 */, 167 /* 0xa7 */, - 168 /* 0xa8 */, 169 /* 0xa9 */, 170 /* 0xaa */, 171 /* 0xab */, - 172 /* 0xac */, 173 /* 0xad */, 174 /* 0xae */, 175 /* 0xaf */, - 176 /* 0xb0 */, 177 /* 0xb1 */, 178 /* 0xb2 */, 179 /* 0xb3 */, - 180 /* 0xb4 */, 181 /* 0xb5 */, 182 /* 0xb6 */, 183 /* 0xb7 */, - 184 /* 0xb8 */, 185 /* 0xb9 */, 186 /* 0xba */, 187 /* 0xbb */, - 188 /* 0xbc */, 189 /* 0xbd */, 190 /* 0xbe */, 191 /* 0xbf */, - 192 /* 0xc0 */, 193 /* 0xc1 */, 194 /* 0xc2 */, 195 /* 0xc3 */, - 196 /* 0xc4 */, 197 /* 0xc5 */, 198 /* 0xc6 */, 199 /* 0xc7 */, - 200 /* 0xc8 */, 201 /* 0xc9 */, 202 /* 0xca */, 203 /* 0xcb */, - 204 /* 0xcc */, 205 /* 0xcd */, 206 /* 0xce */, 207 /* 0xcf */, - 208 /* 0xd0 */, 209 /* 0xd1 */, 210 /* 0xd2 */, 211 /* 0xd3 */, - 212 /* 0xd4 */, 213 /* 0xd5 */, 214 /* 0xd6 */, 215 /* 0xd7 */, - 216 /* 0xd8 */, 217 /* 0xd9 */, 218 /* 0xda */, 219 /* 0xdb */, - 220 /* 0xdc */, 221 /* 0xdd */, 222 /* 0xde */, 223 /* 0xdf */, - 224 /* 0xe0 */, 225 /* 0xe1 */, 226 /* 0xe2 */, 227 /* 0xe3 */, - 228 /* 0xe4 */, 229 /* 0xe5 */, 230 /* 0xe6 */, 231 /* 0xe7 */, - 232 /* 0xe8 */, 233 /* 0xe9 */, 234 /* 0xea */, 235 /* 0xeb */, - 236 /* 0xec */, 237 /* 0xed */, 238 /* 0xee */, 239 /* 0xef */, - 240 /* 0xf0 */, 241 /* 0xf1 */, 242 /* 0xf2 */, 243 /* 0xf3 */, - 244 /* 0xf4 */, 245 /* 0xf5 */, 246 /* 0xf6 */, 247 /* 0xf7 */, - 248 /* 0xf8 */, 249 /* 0xf9 */, 250 /* 0xfa */, 251 /* 0xfb */, - 252 /* 0xfc */, 253 /* 0xfd */, 254 /* 0xfe */, 255 /* 0xff */, + 152 /* 0x98 */, 153 /* 0x99 */, 154 /* 0x9A */, 155 /* 0x9B */, + 156 /* 0x9C */, 157 /* 0x9D */, 158 /* 0x9E */, 159 /* 0x9F */, + 160 /* 0xA0 */, 161 /* 0xA1 */, 162 /* 0xA2 */, 163 /* 0xA3 */, + 164 /* 0xA4 */, 165 /* 0xA5 */, 166 /* 0xA6 */, 167 /* 0xA7 */, + 168 /* 0xA8 */, 169 /* 0xA9 */, 170 /* 0xAA */, 171 /* 0xAB */, + 172 /* 0xAC */, 173 /* 0xAD */, 174 /* 0xAE */, 175 /* 0xAF */, + 176 /* 0xB0 */, 177 /* 0xB1 */, 178 /* 0xB2 */, 179 /* 0xB3 */, + 180 /* 0xB4 */, 181 /* 0xB5 */, 182 /* 0xB6 */, 183 /* 0xB7 */, + 184 /* 0xB8 */, 185 /* 0xB9 */, 186 /* 0xBA */, 187 /* 0xBB */, + 188 /* 0xBC */, 189 /* 0xBD */, 190 /* 0xBE */, 191 /* 0xBF */, + 192 /* 0xC0 */, 193 /* 0xC1 */, 194 /* 0xC2 */, 195 /* 0xC3 */, + 196 /* 0xC4 */, 197 /* 0xC5 */, 198 /* 0xC6 */, 199 /* 0xC7 */, + 200 /* 0xC8 */, 201 /* 0xC9 */, 202 /* 0xCA */, 203 /* 0xCB */, + 204 /* 0xCC */, 205 /* 0xCD */, 206 /* 0xCE */, 207 /* 0xCF */, + 208 /* 0xD0 */, 209 /* 0xD1 */, 210 /* 0xD2 */, 211 /* 0xD3 */, + 212 /* 0xD4 */, 213 /* 0xD5 */, 214 /* 0xD6 */, 215 /* 0xD7 */, + 216 /* 0xD8 */, 217 /* 0xD9 */, 218 /* 0xDA */, 219 /* 0xDB */, + 220 /* 0xDC */, 221 /* 0xDD */, 222 /* 0xDE */, 223 /* 0xDF */, + 224 /* 0xE0 */, 225 /* 0xE1 */, 226 /* 0xE2 */, 227 /* 0xE3 */, + 228 /* 0xE4 */, 229 /* 0xE5 */, 230 /* 0xE6 */, 231 /* 0xE7 */, + 232 /* 0xE8 */, 233 /* 0xE9 */, 234 /* 0xEA */, 235 /* 0xEB */, + 236 /* 0xEC */, 237 /* 0xED */, 238 /* 0xEE */, 239 /* 0xEF */, + 240 /* 0xF0 */, 241 /* 0xF1 */, 242 /* 0xF2 */, 243 /* 0xF3 */, + 244 /* 0xF4 */, 245 /* 0xF5 */, 246 /* 0xF6 */, 247 /* 0xF7 */, + 248 /* 0xF8 */, 249 /* 0xF9 */, 250 /* 0xFA */, 251 /* 0xFB */, + 252 /* 0xFC */, 253 /* 0xFD */, 254 /* 0xFE */, 255 /* 0xFF */, }; void nghttp3_downcase(uint8_t *s, size_t len) { diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_stream.c b/deps/ngtcp2/nghttp3/lib/nghttp3_stream.c index 202217a4c6f28b..8acf0da817b54a 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_stream.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_stream.c @@ -177,11 +177,11 @@ void nghttp3_stream_del(nghttp3_stream *stream) { } void nghttp3_varint_read_state_reset(nghttp3_varint_read_state *rvint) { - memset(rvint, 0, sizeof(*rvint)); + *rvint = (nghttp3_varint_read_state){0}; } void nghttp3_stream_read_state_reset(nghttp3_stream_read_state *rstate) { - memset(rstate, 0, sizeof(*rstate)); + *rstate = (nghttp3_stream_read_state){0}; } nghttp3_ssize nghttp3_read_varint(nghttp3_varint_read_state *rvint, @@ -195,10 +195,10 @@ nghttp3_ssize nghttp3_read_varint(nghttp3_varint_read_state *rvint, if (rvint->left == 0) { assert(rvint->acc == 0); - vlen = nghttp3_get_varintlen(begin); - len = nghttp3_min_size(vlen, (size_t)(end - begin)); + vlen = nghttp3_get_uvarintlen(begin); + len = nghttp3_min(vlen, (size_t)(end - begin)); if (vlen <= len) { - nghttp3_get_varint(&rvint->acc, begin); + nghttp3_get_uvarint(&rvint->acc, begin); return (nghttp3_ssize)vlen; } @@ -208,19 +208,19 @@ nghttp3_ssize nghttp3_read_varint(nghttp3_varint_read_state *rvint, p = (uint8_t *)&rvint->acc + (sizeof(rvint->acc) - vlen); memcpy(p, begin, len); - *p &= 0x3f; + *p &= 0x3FU; rvint->left = vlen - len; return (nghttp3_ssize)len; } - len = nghttp3_min_size(rvint->left, (size_t)(end - begin)); + len = nghttp3_min(rvint->left, (size_t)(end - begin)); p = (uint8_t *)&rvint->acc + (sizeof(rvint->acc) - rvint->left); memcpy(p, begin, len); rvint->left -= len; if (rvint->left == 0) { - rvint->acc = (int64_t)nghttp3_ntohl64((uint64_t)rvint->acc); + rvint->acc = nghttp3_ntohl64(rvint->acc); } else if (fin) { return NGHTTP3_ERR_INVALID_ARGUMENT; } @@ -228,22 +228,19 @@ nghttp3_ssize nghttp3_read_varint(nghttp3_varint_read_state *rvint, return (nghttp3_ssize)len; } -int nghttp3_stream_frq_add(nghttp3_stream *stream, const nghttp3_frame *fr) { +int nghttp3_stream_frq_emplace(nghttp3_stream *stream, nghttp3_frame **pfr) { nghttp3_ringbuf *frq = &stream->frq; - nghttp3_frame *dest; int rv; if (nghttp3_ringbuf_full(frq)) { - size_t nlen = - nghttp3_max_size(NGHTTP3_MIN_RBLEN, nghttp3_ringbuf_len(frq) * 2); + size_t nlen = nghttp3_max(NGHTTP3_MIN_RBLEN, nghttp3_ringbuf_len(frq) * 2); rv = nghttp3_ringbuf_reserve(frq, nlen); if (rv != 0) { return rv; } } - dest = nghttp3_ringbuf_push_back(frq); - *dest = *fr; + *pfr = nghttp3_ringbuf_push_back(frq); return 0; } @@ -357,7 +354,7 @@ int nghttp3_stream_fill_outq(nghttp3_stream *stream) { } int nghttp3_stream_write_stream_type(nghttp3_stream *stream) { - size_t len = nghttp3_put_varintlen((int64_t)stream->type); + size_t len = nghttp3_put_uvarintlen(stream->type); nghttp3_buf *chunk; nghttp3_typed_buf tbuf; int rv; @@ -370,7 +367,7 @@ int nghttp3_stream_write_stream_type(nghttp3_stream *stream) { chunk = nghttp3_stream_get_chunk(stream); nghttp3_typed_buf_shared_init(&tbuf, chunk); - chunk->last = nghttp3_put_varint(chunk->last, (int64_t)stream->type); + chunk->last = nghttp3_put_uvarint(chunk->last, stream->type); tbuf.buf.last = chunk->last; return nghttp3_stream_outq_add(stream, &tbuf); @@ -389,7 +386,7 @@ int nghttp3_stream_write_settings(nghttp3_stream *stream, .iv = ents, }; const nghttp3_settings *local_settings = infr->local_settings; - int64_t payloadlen; + uint64_t payloadlen; ents[0] = (nghttp3_settings_entry){ .id = NGHTTP3_SETTINGS_ID_MAX_FIELD_SECTION_SIZE, @@ -470,7 +467,7 @@ int nghttp3_stream_write_goaway(nghttp3_stream *stream, int rv; nghttp3_buf *chunk; nghttp3_typed_buf tbuf; - int64_t payloadlen; + uint64_t payloadlen; len = nghttp3_frame_write_goaway_len(&payloadlen, fr); @@ -495,7 +492,7 @@ int nghttp3_stream_write_priority_update( int rv; nghttp3_buf *chunk; nghttp3_typed_buf tbuf; - int64_t payloadlen; + uint64_t payloadlen; len = nghttp3_frame_write_priority_update_len(&payloadlen, fr); @@ -523,7 +520,7 @@ int nghttp3_stream_write_origin(nghttp3_stream *stream, int rv; rv = nghttp3_stream_ensure_chunk( - stream, nghttp3_frame_write_hd_len(fr->type, (int64_t)fr->origin_list.len)); + stream, nghttp3_frame_write_hd_len(fr->type, fr->origin_list.len)); if (rv != 0) { return rv; } @@ -532,7 +529,7 @@ int nghttp3_stream_write_origin(nghttp3_stream *stream, nghttp3_typed_buf_shared_init(&tbuf, chunk); chunk->last = - nghttp3_frame_write_hd(chunk->last, fr->type, (int64_t)fr->origin_list.len); + nghttp3_frame_write_hd(chunk->last, fr->type, fr->origin_list.len); tbuf.buf.last = chunk->last; @@ -584,7 +581,7 @@ int nghttp3_stream_write_wt_stream_data(nghttp3_stream *stream, int *peof, nghttp3_buf buf; nghttp3_read_data_callback read_data = fr->dr.read_data; nghttp3_conn *conn = stream->conn; - int64_t datalen; + uint64_t datalen; uint32_t flags = 0; nghttp3_vec vec[8]; nghttp3_vec *v; @@ -607,8 +604,8 @@ int nghttp3_stream_write_wt_stream_data(nghttp3_stream *stream, int *peof, return NGHTTP3_ERR_CALLBACK_FAILURE; } - datalen = nghttp3_vec_len_varint(vec, (size_t)sveccnt); - if (datalen == -1) { + rv = nghttp3_vec_len_uvarint(&datalen, vec, (size_t)sveccnt); + if (rv != 0) { return NGHTTP3_ERR_STREAM_DATA_OVERFLOW; } @@ -661,9 +658,8 @@ int nghttp3_stream_write_cpsl_wt_close_session( nghttp3_buf buf; nghttp3_typed_buf tbuf; size_t cpsl_payloadlen = sizeof(fr->error_code) + fr->error_msg.len; - size_t fr_hdlen = - nghttp3_frame_write_hd_len(fr->type, (int64_t)cpsl_payloadlen); - int64_t payloadlen = (int64_t)(fr_hdlen + cpsl_payloadlen); + size_t fr_hdlen = nghttp3_frame_write_hd_len(fr->type, cpsl_payloadlen); + uint64_t payloadlen = fr_hdlen + cpsl_payloadlen; rv = nghttp3_stream_ensure_chunk( stream, nghttp3_frame_write_hd_len(NGHTTP3_FRAME_DATA, payloadlen) + @@ -677,8 +673,7 @@ int nghttp3_stream_write_cpsl_wt_close_session( chunk->last = nghttp3_frame_write_hd(chunk->last, NGHTTP3_FRAME_DATA, payloadlen); - chunk->last = - nghttp3_frame_write_hd(chunk->last, fr->type, (int64_t)cpsl_payloadlen); + chunk->last = nghttp3_frame_write_hd(chunk->last, fr->type, cpsl_payloadlen); chunk->last = nghttp3_put_uint32be(chunk->last, fr->error_code); tbuf.buf.last = chunk->last; @@ -714,8 +709,8 @@ int nghttp3_stream_write_header_block(nghttp3_stream *stream, nghttp3_qpack_encoder *qenc, nghttp3_stream *qenc_stream, nghttp3_buf *rbuf, nghttp3_buf *ebuf, - int64_t frame_type, const nghttp3_nv *nva, - size_t nvlen) { + uint64_t frame_type, + const nghttp3_nv *nva, size_t nvlen) { nghttp3_buf pbuf; int rv; size_t len; @@ -723,7 +718,7 @@ int nghttp3_stream_write_header_block(nghttp3_stream *stream, nghttp3_typed_buf tbuf; uint8_t raw_pbuf[16]; size_t pbuflen, rbuflen, ebuflen; - int64_t payloadlen; + uint64_t payloadlen; nghttp3_buf_wrap_init(&pbuf, raw_pbuf, sizeof(raw_pbuf)); @@ -737,7 +732,7 @@ int nghttp3_stream_write_header_block(nghttp3_stream *stream, rbuflen = nghttp3_buf_len(rbuf); ebuflen = nghttp3_buf_len(ebuf); - payloadlen = (int64_t)(pbuflen + rbuflen); + payloadlen = pbuflen + rbuflen; len = nghttp3_frame_write_hd_len(frame_type, payloadlen) + pbuflen; @@ -829,7 +824,7 @@ int nghttp3_stream_write_data(nghttp3_stream *stream, int *peof, nghttp3_buf *chunk; nghttp3_read_data_callback read_data = fr->dr.read_data; nghttp3_conn *conn = stream->conn; - int64_t datalen; + uint64_t datalen; uint32_t flags = 0; nghttp3_vec vec[8]; nghttp3_vec *v; @@ -852,8 +847,8 @@ int nghttp3_stream_write_data(nghttp3_stream *stream, int *peof, return NGHTTP3_ERR_CALLBACK_FAILURE; } - datalen = nghttp3_vec_len_varint(vec, (size_t)sveccnt); - if (datalen == -1) { + rv = nghttp3_vec_len_uvarint(&datalen, vec, (size_t)sveccnt); + if (rv == -1) { return NGHTTP3_ERR_STREAM_DATA_OVERFLOW; } @@ -937,7 +932,7 @@ int nghttp3_stream_write_qpack_decoder_stream(nghttp3_stream *stream) { assert(qdec); - len = nghttp3_qpack_decoder_get_decoder_streamlen(qdec); + len = nghttp3_qpack_decoder_get_decoder_streamlen2(qdec); if (len == 0) { return 0; } @@ -991,7 +986,7 @@ int nghttp3_stream_outq_add(nghttp3_stream *stream, } if (nghttp3_ringbuf_full(outq)) { - size_t nlen = nghttp3_max_size(NGHTTP3_MIN_RBLEN, len * 2); + size_t nlen = nghttp3_max(NGHTTP3_MIN_RBLEN, len * 2); rv = nghttp3_ringbuf_reserve(outq, nlen); if (rv != 0) { return rv; @@ -1033,7 +1028,7 @@ int nghttp3_stream_ensure_chunk(nghttp3_stream *stream, size_t need) { } if (nghttp3_ringbuf_full(chunks)) { - size_t nlen = nghttp3_max_size(NGHTTP3_MIN_RBLEN, len * 2); + size_t nlen = nghttp3_max(NGHTTP3_MIN_RBLEN, len * 2); rv = nghttp3_ringbuf_reserve(chunks, nlen); if (rv != 0) { return rv; @@ -1055,13 +1050,13 @@ nghttp3_buf *nghttp3_stream_get_chunk(nghttp3_stream *stream) { return nghttp3_ringbuf_get(chunks, len - 1); } -int nghttp3_stream_is_blocked(nghttp3_stream *stream) { +int nghttp3_stream_is_blocked(const nghttp3_stream *stream) { return (stream->flags & NGHTTP3_STREAM_FLAG_FC_BLOCKED) || (stream->flags & NGHTTP3_STREAM_FLAG_SHUT_WR) || (stream->flags & NGHTTP3_STREAM_FLAG_READ_DATA_BLOCKED); } -int nghttp3_stream_require_schedule(nghttp3_stream *stream) { +int nghttp3_stream_require_schedule(const nghttp3_stream *stream) { return (!nghttp3_stream_outq_write_done(stream) && !(stream->flags & NGHTTP3_STREAM_FLAG_FC_BLOCKED) && !(stream->flags & NGHTTP3_STREAM_FLAG_SHUT_WR)) || @@ -1134,8 +1129,8 @@ void nghttp3_stream_add_outq_offset(nghttp3_stream *stream, size_t n) { stream->outq_idx = i; } -int nghttp3_stream_outq_write_done(nghttp3_stream *stream) { - nghttp3_ringbuf *outq = &stream->outq; +int nghttp3_stream_outq_write_done(const nghttp3_stream *stream) { + const nghttp3_ringbuf *outq = &stream->outq; size_t len = nghttp3_ringbuf_len(outq); return len == 0 || stream->outq_idx >= len; @@ -1191,8 +1186,8 @@ int nghttp3_stream_update_ack_offset(nghttp3_stream *stream, uint64_t offset) { /* For NGHTTP3_BUF_TYPE_ALIEN, we never add 0 length buffer. */ if (tbuf->type == NGHTTP3_BUF_TYPE_ALIEN && stream->ack_offset < offset && stream->callbacks.acked_data) { - nack = nghttp3_min_uint64(offset, stream->ack_base + buflen) - - stream->ack_offset; + nack = + nghttp3_min(offset, stream->ack_base + buflen) - stream->ack_offset; rv = stream->callbacks.acked_data(stream, stream->node.id, nack, stream->user_data); @@ -1233,7 +1228,7 @@ int nghttp3_stream_buffer_data(nghttp3_stream *stream, const uint8_t *data, if (len) { buf = nghttp3_ringbuf_get(inq, len - 1); bufleft = nghttp3_buf_left(buf); - nwrite = nghttp3_min_size(datalen, bufleft); + nwrite = nghttp3_min(datalen, bufleft); buf->last = nghttp3_cpymem(buf->last, data, nwrite); data += nwrite; datalen -= nwrite; @@ -1242,7 +1237,7 @@ int nghttp3_stream_buffer_data(nghttp3_stream *stream, const uint8_t *data, for (; datalen;) { if (nghttp3_ringbuf_full(inq)) { size_t nlen = - nghttp3_max_size(NGHTTP3_MIN_RBLEN, nghttp3_ringbuf_len(inq) * 2); + nghttp3_max(NGHTTP3_MIN_RBLEN, nghttp3_ringbuf_len(inq) * 2); rv = nghttp3_ringbuf_reserve(inq, nlen); if (rv != 0) { return rv; @@ -1257,7 +1252,7 @@ int nghttp3_stream_buffer_data(nghttp3_stream *stream, const uint8_t *data, buf = nghttp3_ringbuf_push_back(inq); nghttp3_buf_wrap_init(buf, rawbuf, 16384); bufleft = nghttp3_buf_left(buf); - nwrite = nghttp3_min_size(datalen, bufleft); + nwrite = nghttp3_min(datalen, bufleft); buf->last = nghttp3_cpymem(buf->last, data, nwrite); data += nwrite; datalen -= nwrite; @@ -1451,7 +1446,7 @@ int nghttp3_stream_transit_rx_http_state(nghttp3_stream *stream, } } -int nghttp3_stream_empty_headers_allowed(nghttp3_stream *stream) { +int nghttp3_stream_empty_headers_allowed(const nghttp3_stream *stream) { switch (stream->rx.hstate) { case NGHTTP3_HTTP_STATE_REQ_TRAILERS_BEGIN: case NGHTTP3_HTTP_STATE_RESP_TRAILERS_BEGIN: diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_stream.h b/deps/ngtcp2/nghttp3/lib/nghttp3_stream.h index 33db7d173d820f..59ff74866267ef 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_stream.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_stream.h @@ -52,11 +52,11 @@ /* nghttp3_stream_type is unidirectional stream type. */ typedef uint64_t nghttp3_stream_type; -#define NGHTTP3_STREAM_TYPE_CONTROL 0x00 -#define NGHTTP3_STREAM_TYPE_PUSH 0x01 -#define NGHTTP3_STREAM_TYPE_QPACK_ENCODER 0x02 -#define NGHTTP3_STREAM_TYPE_QPACK_DECODER 0x03 -#define NGHTTP3_STREAM_TYPE_WT_STREAM 0x54 +#define NGHTTP3_STREAM_TYPE_CONTROL 0x00U +#define NGHTTP3_STREAM_TYPE_PUSH 0x01U +#define NGHTTP3_STREAM_TYPE_QPACK_ENCODER 0x02U +#define NGHTTP3_STREAM_TYPE_QPACK_DECODER 0x03U +#define NGHTTP3_STREAM_TYPE_WT_STREAM 0x54U #define NGHTTP3_STREAM_TYPE_UNKNOWN UINT64_MAX typedef enum nghttp3_ctrl_stream_state { @@ -93,7 +93,7 @@ typedef enum nghttp3_wt_stream_state { } nghttp3_wt_stream_state; typedef struct nghttp3_varint_read_state { - int64_t acc; + uint64_t acc; size_t left; } nghttp3_varint_read_state; @@ -101,58 +101,57 @@ typedef struct nghttp3_stream_read_state { nghttp3_varint_read_state rvint; nghttp3_settings_entry iv; nghttp3_frame fr; - int64_t left; + uint64_t left; int state; } nghttp3_stream_read_state; typedef struct nghttp3_wt_session nghttp3_wt_session; /* NGHTTP3_STREAM_FLAG_NONE indicates that no flag is set. */ -#define NGHTTP3_STREAM_FLAG_NONE 0x0000u +#define NGHTTP3_STREAM_FLAG_NONE 0x0000U /* NGHTTP3_STREAM_FLAG_TYPE_IDENTIFIED is set when a unidirectional stream type is identified. */ -#define NGHTTP3_STREAM_FLAG_TYPE_IDENTIFIED 0x0001u +#define NGHTTP3_STREAM_FLAG_TYPE_IDENTIFIED 0x0001U /* NGHTTP3_STREAM_FLAG_FC_BLOCKED indicates that stream is blocked by QUIC flow control. */ -#define NGHTTP3_STREAM_FLAG_FC_BLOCKED 0x0002u +#define NGHTTP3_STREAM_FLAG_FC_BLOCKED 0x0002U /* NGHTTP3_STREAM_FLAG_READ_DATA_BLOCKED indicates that application is temporarily unable to provide data. */ -#define NGHTTP3_STREAM_FLAG_READ_DATA_BLOCKED 0x0004u +#define NGHTTP3_STREAM_FLAG_READ_DATA_BLOCKED 0x0004U /* NGHTTP3_STREAM_FLAG_WRITE_END_STREAM indicates that application finished to feed outgoing data. */ -#define NGHTTP3_STREAM_FLAG_WRITE_END_STREAM 0x0008u +#define NGHTTP3_STREAM_FLAG_WRITE_END_STREAM 0x0008U /* NGHTTP3_STREAM_FLAG_QPACK_DECODE_BLOCKED indicates that stream is blocked due to QPACK decoding. */ -#define NGHTTP3_STREAM_FLAG_QPACK_DECODE_BLOCKED 0x0010u +#define NGHTTP3_STREAM_FLAG_QPACK_DECODE_BLOCKED 0x0010U /* NGHTTP3_STREAM_FLAG_READ_EOF indicates that remote endpoint sent fin. */ -#define NGHTTP3_STREAM_FLAG_READ_EOF 0x0020u +#define NGHTTP3_STREAM_FLAG_READ_EOF 0x0020U /* NGHTTP3_STREAM_FLAG_SHUT_WR indicates that any further write operation to a stream is prohibited. */ -#define NGHTTP3_STREAM_FLAG_SHUT_WR 0x0100u +#define NGHTTP3_STREAM_FLAG_SHUT_WR 0x0100U /* NGHTTP3_STREAM_FLAG_SHUT_RD indicates that a read-side stream is closed abruptly and any incoming and pending stream data is just discarded for a stream. */ -#define NGHTTP3_STREAM_FLAG_SHUT_RD 0x0200u +#define NGHTTP3_STREAM_FLAG_SHUT_RD 0x0200U /* NGHTTP3_STREAM_FLAG_SERVER_PRIORITY_SET indicates that server overrides stream priority. */ -#define NGHTTP3_STREAM_FLAG_SERVER_PRIORITY_SET 0x0400u +#define NGHTTP3_STREAM_FLAG_SERVER_PRIORITY_SET 0x0400U /* NGHTTP3_STREAM_FLAG_PRIORITY_UPDATE_RECVED indicates that server received PRIORITY_UPDATE frame for this stream. */ - -#define NGHTTP3_STREAM_FLAG_PRIORITY_UPDATE_RECVED 0x0800u +#define NGHTTP3_STREAM_FLAG_PRIORITY_UPDATE_RECVED 0x0800U /* NGHTTP3_STREAM_FLAG_MAYBE_WT_DATA indicates that the stream may be WebTransport data stream. */ -#define NGHTTP3_STREAM_FLAG_MAYBE_WT_DATA 0x1000u +#define NGHTTP3_STREAM_FLAG_MAYBE_WT_DATA 0x1000U /* NGHTTP3_STREAM_FLAG_WT_DATA indicates that the stream is WebTransport data stream. */ -#define NGHTTP3_STREAM_FLAG_WT_DATA 0x2000u +#define NGHTTP3_STREAM_FLAG_WT_DATA 0x2000U /* NGHTTP3_STREAM_FLAG_WT_SESSION_BLOCKED indicates that the stream is blocked because WebTransport session has not been established. */ -#define NGHTTP3_STREAM_FLAG_WT_SESSION_BLOCKED 0x4000u +#define NGHTTP3_STREAM_FLAG_WT_SESSION_BLOCKED 0x4000U /* NGHTTP3_STREAM_FLAG_RESP_SUBMITTED indicates that HTTP/3 response has been submitted via nghttp3_conn_submit_response. */ -#define NGHTTP3_STREAM_FLAG_RESP_SUBMITTED 0x8000u +#define NGHTTP3_STREAM_FLAG_RESP_SUBMITTED 0x8000U typedef enum nghttp3_stream_http_state { NGHTTP3_HTTP_STATE_NONE, @@ -293,7 +292,18 @@ nghttp3_ssize nghttp3_read_varint(nghttp3_varint_read_state *rvint, const uint8_t *begin, const uint8_t *end, int fin); -int nghttp3_stream_frq_add(nghttp3_stream *stream, const nghttp3_frame *fr); +/* + * nghttp3_stream_frq_emplace adds new space for nghttp3_frame to + * stream->frq, and assigns the pointer to the space to |*pfr| if it + * succeeds. + * + * This function returns 0 if it succeeds, or one of the following + * negative error codes: + * + * NGHTTP3_ERR_NOMEM + * Out of memory. + */ +int nghttp3_stream_frq_emplace(nghttp3_stream *stream, nghttp3_frame **pfr); int nghttp3_stream_fill_outq(nghttp3_stream *stream); @@ -314,8 +324,8 @@ int nghttp3_stream_write_header_block(nghttp3_stream *stream, nghttp3_qpack_encoder *qenc, nghttp3_stream *qenc_stream, nghttp3_buf *rbuf, nghttp3_buf *ebuf, - int64_t frame_type, const nghttp3_nv *nva, - size_t nvlen); + uint64_t frame_type, + const nghttp3_nv *nva, size_t nvlen); int nghttp3_stream_write_data(nghttp3_stream *stream, int *peof, const nghttp3_frame_data *fr); @@ -345,7 +355,7 @@ int nghttp3_stream_ensure_chunk(nghttp3_stream *stream, size_t need); nghttp3_buf *nghttp3_stream_get_chunk(nghttp3_stream *stream); -int nghttp3_stream_is_blocked(nghttp3_stream *stream); +int nghttp3_stream_is_blocked(const nghttp3_stream *stream); void nghttp3_stream_add_outq_offset(nghttp3_stream *stream, size_t n); @@ -353,7 +363,7 @@ void nghttp3_stream_add_outq_offset(nghttp3_stream *stream, size_t n); * nghttp3_stream_outq_write_done returns nonzero if all contents in * outq have been written. */ -int nghttp3_stream_outq_write_done(nghttp3_stream *stream); +int nghttp3_stream_outq_write_done(const nghttp3_stream *stream); /* * nghttp2_stream_update_ack_offset updates the last acknowledged @@ -373,7 +383,7 @@ int nghttp3_stream_is_active(nghttp3_stream *stream); * be scheduled. In other words, |stream| or its descendants have * something to send. */ -int nghttp3_stream_require_schedule(nghttp3_stream *stream); +int nghttp3_stream_require_schedule(const nghttp3_stream *stream); int nghttp3_stream_schedulable(const nghttp3_stream *stream); @@ -389,7 +399,7 @@ void nghttp3_stream_delete_qpack_stream_context(nghttp3_stream *stream); int nghttp3_stream_transit_rx_http_state(nghttp3_stream *stream, nghttp3_stream_http_event event); -int nghttp3_stream_empty_headers_allowed(nghttp3_stream *stream); +int nghttp3_stream_empty_headers_allowed(const nghttp3_stream *stream); int nghttp3_stream_wt_ctrl(const nghttp3_stream *stream); diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_tnode.c b/deps/ngtcp2/nghttp3/lib/nghttp3_tnode.c index 4a969df1946386..f8f4be9477c4f2 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_tnode.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_tnode.c @@ -56,7 +56,7 @@ void nghttp3_tnode_unschedule(nghttp3_tnode *tnode, nghttp3_pq *pq) { tnode_unschedule(tnode, pq); } -static uint64_t pq_get_first_cycle(nghttp3_pq *pq) { +static uint64_t pq_get_first_cycle(const nghttp3_pq *pq) { nghttp3_tnode *top; if (nghttp3_pq_empty(pq)) { @@ -74,7 +74,7 @@ int nghttp3_tnode_schedule(nghttp3_tnode *tnode, nghttp3_pq *pq, if (tnode->pe.index == NGHTTP3_PQ_BAD_INDEX) { tnode->cycle = pq_get_first_cycle(pq) + - ((nwrite == 0 || !tnode->pri.inc) ? 0 : nghttp3_max_uint64(1, penalty)); + ((nwrite == 0 || !tnode->pri.inc) ? 0 : nghttp3_max(1, penalty)); } else if (nwrite > 0) { if (!tnode->pri.inc || nghttp3_pq_size(pq) == 1) { return 0; @@ -82,7 +82,7 @@ int nghttp3_tnode_schedule(nghttp3_tnode *tnode, nghttp3_pq *pq, nghttp3_pq_remove(pq, &tnode->pe); tnode->pe.index = NGHTTP3_PQ_BAD_INDEX; - tnode->cycle += nghttp3_max_uint64(1, penalty); + tnode->cycle += nghttp3_max(1, penalty); } else { return 0; } @@ -90,6 +90,6 @@ int nghttp3_tnode_schedule(nghttp3_tnode *tnode, nghttp3_pq *pq, return nghttp3_pq_push(pq, &tnode->pe); } -int nghttp3_tnode_is_scheduled(nghttp3_tnode *tnode) { +int nghttp3_tnode_is_scheduled(const nghttp3_tnode *tnode) { return tnode->pe.index != NGHTTP3_PQ_BAD_INDEX; } diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_tnode.h b/deps/ngtcp2/nghttp3/lib/nghttp3_tnode.h index 297067d7ca0332..954f6fff040dc3 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_tnode.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_tnode.h @@ -33,13 +33,12 @@ #include "nghttp3_pq.h" -#define NGHTTP3_TNODE_MAX_CYCLE_GAP (1llu << 24) +#define NGHTTP3_TNODE_MAX_CYCLE_GAP (1ULL << 24) typedef struct nghttp3_tnode { nghttp3_pq_entry pe; int64_t id; uint64_t cycle; - /* pri is a stream priority produced by nghttp3_pri_to_uint8. */ nghttp3_pri pri; } nghttp3_tnode; @@ -60,6 +59,6 @@ int nghttp3_tnode_schedule(nghttp3_tnode *tnode, nghttp3_pq *pq, /* * nghttp3_tnode_is_scheduled returns nonzero if |tnode| is scheduled. */ -int nghttp3_tnode_is_scheduled(nghttp3_tnode *tnode); +int nghttp3_tnode_is_scheduled(const nghttp3_tnode *tnode); #endif /* !defined(NGHTTP3_TNODE_H) */ diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_vec.c b/deps/ngtcp2/nghttp3/lib/nghttp3_vec.c index ab58ff5832bea9..7302e88111bd49 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_vec.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_vec.c @@ -37,7 +37,7 @@ uint64_t nghttp3_vec_len(const nghttp3_vec *vec, size_t n) { return res; } -int64_t nghttp3_vec_len_varint(const nghttp3_vec *vec, size_t n) { +int nghttp3_vec_len_uvarint(uint64_t *dest, const nghttp3_vec *vec, size_t n) { uint64_t res = 0; size_t len; size_t i; @@ -51,5 +51,7 @@ int64_t nghttp3_vec_len_varint(const nghttp3_vec *vec, size_t n) { res += len; } - return (int64_t)res; + *dest = res; + + return 0; } diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_vec.h b/deps/ngtcp2/nghttp3/lib/nghttp3_vec.h index f36eabc1052621..ad63f4fedfb2b6 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_vec.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_vec.h @@ -33,9 +33,11 @@ #include /* - * nghttp3_vec_len_varint is similar to nghttp3_vec_len, but it - * returns -1 if the sum of the length exceeds NGHTTP3_MAX_VARINT. + * nghttp3_vec_len_uvarint is similar to nghttp3_vec_len, but it + * stores the return value from nghttp3_vec_len(|vec|, |n|) into + * |dest| if it does not exceed NGHTTP3_MAX_VARINT, and returns 0. + * Otherwise returns -1. */ -int64_t nghttp3_vec_len_varint(const nghttp3_vec *vec, size_t n); +int nghttp3_vec_len_uvarint(uint64_t *dest, const nghttp3_vec *vec, size_t n); #endif /* !defined(NGHTTP3_VEC_H) */ diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_wt.c b/deps/ngtcp2/nghttp3/lib/nghttp3_wt.c index cb7260797e945c..1fad630efe6744 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_wt.c +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_wt.c @@ -143,9 +143,8 @@ int nghttp3_wt_session_read_stream(nghttp3_wt_session *wts, const uint8_t *src, switch (rstate->cpsl.hd.type) { case NGHTTP3_EXFR_CPSL_WT_CLOSE_SESSION: - if (rstate->left < (int64_t)sizeof(uint32_t) || - rstate->left > - (int64_t)sizeof(uint32_t) + /* largest message size */ 1024) { + if (rstate->left < sizeof(uint32_t) || + rstate->left > sizeof(uint32_t) + /* largest message size */ 1024) { /* TODO Find better error code */ return NGHTTP3_ERR_H3_MESSAGE_ERROR; } @@ -168,15 +167,14 @@ int nghttp3_wt_session_read_stream(nghttp3_wt_session *wts, const uint8_t *src, break; case NGHTTP3_WT_CTRL_STREAM_STATE_WT_CLOSE_SESSION_ERROR_CODE: - len = (size_t)nghttp3_min_int64((int64_t)rstate->field_left, - (int64_t)(end - p)); + len = nghttp3_min(rstate->field_left, (size_t)(end - p)); for (i = 0; i < len; ++i) { cpsl->wt_close_session.error_code <<= 8; cpsl->wt_close_session.error_code += *p++; } - rstate->left -= (int64_t)len; + rstate->left -= len; rstate->field_left -= len; if (rstate->field_left) { break; @@ -194,9 +192,9 @@ int nghttp3_wt_session_read_stream(nghttp3_wt_session *wts, const uint8_t *src, break; case NGHTTP3_WT_CTRL_STREAM_STATE_WT_CLOSE_SESSION_ERROR_MSG: - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); - rstate->left -= (int64_t)len; + rstate->left -= len; if (rstate->left) { break; } @@ -205,9 +203,9 @@ int nghttp3_wt_session_read_stream(nghttp3_wt_session *wts, const uint8_t *src, return NGHTTP3_ERR_WT_SESSION_GONE; case NGHTTP3_WT_CTRL_STREAM_STATE_IGN: - len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p)); + len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); p += len; - rstate->left -= (int64_t)len; + rstate->left -= len; if (rstate->left) { return 0; diff --git a/deps/ngtcp2/nghttp3/lib/nghttp3_wt.h b/deps/ngtcp2/nghttp3/lib/nghttp3_wt.h index abc35f925055bf..d1f91a786119bd 100644 --- a/deps/ngtcp2/nghttp3/lib/nghttp3_wt.h +++ b/deps/ngtcp2/nghttp3/lib/nghttp3_wt.h @@ -51,7 +51,7 @@ typedef enum nghttp3_wt_ctrl_stream_state { typedef struct nghttp3_wt_ctrl_read_state { nghttp3_varint_read_state rvint; nghttp3_exfr_cpsl cpsl; - int64_t left; + uint64_t left; size_t field_left; int state; } nghttp3_wt_ctrl_read_state; From 1cd20d71203f0c9d22bd1ec76b960ea11868e06c Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 23 May 2026 18:02:24 +0200 Subject: [PATCH 05/10] quic: Implement webtransport settings --- lib/internal/quic/quic.js | 1 + src/quic/application.cc | 10 ++++++-- src/quic/application.h | 1 + src/quic/bindingdata.h | 1 + src/quic/http3.cc | 25 ++++++++++++------- src/quic/session.h | 1 + test/parallel/test-quic-h3-settings.mjs | 1 + .../test-quic-session-application-options.mjs | 2 ++ 8 files changed, 31 insertions(+), 11 deletions(-) diff --git a/lib/internal/quic/quic.js b/lib/internal/quic/quic.js index d237adccd448cc..d069e1958ccdfa 100644 --- a/lib/internal/quic/quic.js +++ b/lib/internal/quic/quic.js @@ -362,6 +362,7 @@ const endpointRegistry = new SafeSet(); * @property {bigint|number} [qpackBlockedStreams] The qpack blocked streams * @property {boolean} [enableConnectProtocol] Enable the connect protocol * @property {boolean} [enableDatagrams] Enable datagrams + * @property {boolean} [enableWebtransport] Enable webtransport */ /** diff --git a/src/quic/application.cc b/src/quic/application.cc index ce5d5e12154d8a..4952b3b71b04a5 100644 --- a/src/quic/application.cc +++ b/src/quic/application.cc @@ -57,6 +57,7 @@ Session::Application_Options::operator const nghttp3_settings() const { .glitch_ratelim_burst = 1000, .glitch_ratelim_rate = 33, .qpack_indexing_strat = NGHTTP3_QPACK_INDEXING_STRAT_EAGER, + .wt_enabled = enable_webtransport }; } @@ -78,6 +79,8 @@ std::string Session::Application_Options::ToString() const { (enable_connect_protocol ? std::string("yes") : std::string("no")); res += prefix + "enable datagrams: " + (enable_datagrams ? std::string("yes") : std::string("no")); + res += prefix + "webtransport enabled: " + + (enable_webtransport ? std::string("yes") : std::string("no")); res += indent.Close(); return res; } @@ -107,7 +110,7 @@ Maybe Session::Application_Options::From( !SET(max_field_section_size) || !SET(qpack_max_dtable_capacity) || !SET(qpack_encoder_max_dtable_capacity) || !SET(qpack_blocked_streams) || !SET(enable_connect_protocol) || - !SET(enable_datagrams)) { + !SET(enable_datagrams) || !SET(enable_webtransport)) { // The call to SetOption should have scheduled an exception to be thrown. return Nothing(); } @@ -138,6 +141,7 @@ MaybeLocal Session::Application_Options::ToObject( "qpackBlockedStreams", "enableConnectProtocol", "enableDatagrams", + "enableWebtransport" }; if (tmpl.IsEmpty()) { tmpl = DictionaryTemplate::New(env->isolate(), names); @@ -153,6 +157,7 @@ MaybeLocal Session::Application_Options::ToObject( BigInt::NewFromUnsigned(env->isolate(), qpack_blocked_streams), Boolean::New(env->isolate(), enable_connect_protocol), Boolean::New(env->isolate(), enable_datagrams), + Boolean::New(env->isolate(), enable_webtransport), }; static_assert(std::size(values) == std::size(names)); @@ -248,7 +253,8 @@ bool Session::Application::ValidateTicketData( options.qpack_blocked_streams >= ticket.qpack_blocked_streams && (!ticket.enable_connect_protocol || options.enable_connect_protocol) && - (!ticket.enable_datagrams || options.enable_datagrams); + (!ticket.enable_datagrams || options.enable_datagrams) && + (!ticket.enable_webtransport || options.enable_webtransport); } // DefaultTicketData always validates. return true; diff --git a/src/quic/application.h b/src/quic/application.h index 0df9b9f0a0e68d..5f2d5adfb57c40 100644 --- a/src/quic/application.h +++ b/src/quic/application.h @@ -25,6 +25,7 @@ struct Http3TicketData { uint64_t qpack_blocked_streams; bool enable_connect_protocol; bool enable_datagrams; + bool enable_webtransport; }; using PendingTicketAppData = std::variant; diff --git a/src/quic/bindingdata.h b/src/quic/bindingdata.h index 2116a35c158ea6..e91a7559b84172 100644 --- a/src/quic/bindingdata.h +++ b/src/quic/bindingdata.h @@ -88,6 +88,7 @@ class SessionManager; V(enable_connect_protocol, "enableConnectProtocol") \ V(enable_early_data, "enableEarlyData") \ V(enable_datagrams, "enableDatagrams") \ + V(enable_webtransport, "enableWebtransport") \ V(enable_tls_trace, "tlsTrace") \ V(endpoint, "Endpoint") \ V(endpoint_udp, "Endpoint::UDP") \ diff --git a/src/quic/http3.cc b/src/quic/http3.cc index bf4bfb42b57611..e5118d318a3b69 100644 --- a/src/quic/http3.cc +++ b/src/quic/http3.cc @@ -29,8 +29,8 @@ namespace quic { namespace { constexpr uint8_t kSessionTicketAppDataVersion = 1; -// Layout: [type(1)][version(1)][crc(4)][payload(34)] = 40 bytes -constexpr size_t kSessionTicketAppDataSize = 40; +// Layout: [type(1)][version(1)][crc(4)][payload(35)] = 41 bytes +constexpr size_t kSessionTicketAppDataSize = 41; constexpr size_t kSessionTicketAppDataHeaderSize = 6; // type + version + crc constexpr size_t kSessionTicketAppDataPayloadSize = kSessionTicketAppDataSize - kSessionTicketAppDataHeaderSize; @@ -406,8 +406,9 @@ class Http3ApplicationImpl final : public Session::Application { WriteBE64(payload + 8, options_.qpack_max_dtable_capacity); WriteBE64(payload + 16, options_.qpack_encoder_max_dtable_capacity); WriteBE64(payload + 24, options_.qpack_blocked_streams); - payload[32] = options_.enable_connect_protocol ? 1 : 0; + payload[32] = options_.enable_connect_protocol ? 1 : 0; // May be bitfield should be used! payload[33] = options_.enable_datagrams ? 1 : 0; + payload[34] = options_.enable_webtransport ? 1 : 0; uLong crc = crc32(0L, Z_NULL, 0); crc = crc32(crc, payload, kSessionTicketAppDataPayloadSize); @@ -460,32 +461,36 @@ class Http3ApplicationImpl final : public Session::Application { uint64_t stored_qpack_blocked_streams = ReadBE64(payload + 24); bool stored_enable_connect_protocol = payload[32] != 0; bool stored_enable_datagrams = payload[33] != 0; + bool stored_enable_webtransport = payload[34] != 0; Debug(&session(), "Ticket app data: stored mfss=%" PRIu64 " qmdc=%" PRIu64 - " qemdc=%" PRIu64 " qbs=%" PRIu64 " ecp=%d ed=%d", + " qemdc=%" PRIu64 " qbs=%" PRIu64 " ecp=%d ed=%d ew=%d", stored_max_field_section_size, stored_qpack_max_dtable_capacity, stored_qpack_encoder_max_dtable_capacity, stored_qpack_blocked_streams, stored_enable_connect_protocol, - stored_enable_datagrams); + stored_enable_datagrams, + stored_enable_webtransport); Debug(&session(), "Current opts: mfss=%" PRIu64 " qmdc=%" PRIu64 " qemdc=%" PRIu64 - " qbs=%" PRIu64 " ecp=%d ed=%d", + " qbs=%" PRIu64 " ecp=%d ed=%d ew %d", options_.max_field_section_size, options_.qpack_max_dtable_capacity, options_.qpack_encoder_max_dtable_capacity, options_.qpack_blocked_streams, options_.enable_connect_protocol, - options_.enable_datagrams); + options_.enable_datagrams, + options_.enable_webtransport); if (options_.max_field_section_size < stored_max_field_section_size || options_.qpack_max_dtable_capacity < stored_qpack_max_dtable_capacity || options_.qpack_encoder_max_dtable_capacity < stored_qpack_encoder_max_dtable_capacity || options_.qpack_blocked_streams < stored_qpack_blocked_streams || (stored_enable_connect_protocol && !options_.enable_connect_protocol) || - (stored_enable_datagrams && !options_.enable_datagrams)) { + (stored_enable_datagrams && !options_.enable_datagrams) || + (stored_enable_webtransport && !options_.enable_webtransport)) { Debug(&session(), "Ticket app data REJECTED"); return SessionTicket::AppData::Status::TICKET_IGNORE_RENEW; } @@ -508,7 +513,8 @@ class Http3ApplicationImpl final : public Session::Application { options_.qpack_blocked_streams >= ticket.qpack_blocked_streams && (!ticket.enable_connect_protocol || options_.enable_connect_protocol) && - (!ticket.enable_datagrams || options_.enable_datagrams); + (!ticket.enable_datagrams || options_.enable_datagrams) && + (!ticket.enable_webtransport || options_.enable_webtransport); } void ReceiveStreamClose(Stream* stream, @@ -1000,6 +1006,7 @@ class Http3ApplicationImpl final : public Session::Application { void OnReceiveSettings(const nghttp3_proto_settings* settings) { options_.enable_connect_protocol = settings->enable_connect_protocol; options_.enable_datagrams = settings->h3_datagram; + options_.enable_webtransport = settings->wt_enabled; options_.max_field_section_size = settings->max_field_section_size; options_.qpack_blocked_streams = settings->qpack_blocked_streams; options_.qpack_max_dtable_capacity = settings->qpack_max_dtable_capacity; diff --git a/src/quic/session.h b/src/quic/session.h index 64c9b8a84d7cf0..d0829ebe01b776 100644 --- a/src/quic/session.h +++ b/src/quic/session.h @@ -83,6 +83,7 @@ class Session final : public AsyncWrap, private SessionTicket::AppData::Source { bool enable_connect_protocol = true; bool enable_datagrams = true; + bool enable_webtransport = false; // for a client always enabling it, may be good operator const nghttp3_settings() const; diff --git a/test/parallel/test-quic-h3-settings.mjs b/test/parallel/test-quic-h3-settings.mjs index 363aa985c23a82..8fc684da8b54b1 100644 --- a/test/parallel/test-quic-h3-settings.mjs +++ b/test/parallel/test-quic-h3-settings.mjs @@ -5,6 +5,7 @@ // maxHeaderLength enforcement - reject headers exceeding byte length // enableConnectProtocol setting (accepted without error) // enableDatagrams setting (accepted without error) +// enableWebtransport setting (accepted without error) import { hasQuic, skip, mustCall } from '../common/index.mjs'; import assert from 'node:assert'; diff --git a/test/parallel/test-quic-session-application-options.mjs b/test/parallel/test-quic-session-application-options.mjs index 1f5c9c0926808c..055983ea10864e 100644 --- a/test/parallel/test-quic-session-application-options.mjs +++ b/test/parallel/test-quic-session-application-options.mjs @@ -25,6 +25,7 @@ const customAppOptions = { qpackBlockedStreams: 50n, enableConnectProtocol: false, enableDatagrams: false, + enableWebtransport: false, }; const serverDone = Promise.withResolvers(); @@ -53,6 +54,7 @@ const serverEndpoint = await listen(mustCall((serverSession) => { strictEqual(opts.enableConnectProtocol, customAppOptions.enableConnectProtocol); strictEqual(opts.enableDatagrams, customAppOptions.enableDatagrams); + strictEqual(opts.enableWebtransport, customAppOptions.enableWebtransport); stream.writer.endSync(); await stream.closed; From 93a14e3a72e25d17f1ce884ffa81a7db64d3b4e5 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sun, 24 May 2026 11:54:50 +0200 Subject: [PATCH 06/10] quic: Implement webtransport response and reply --- lib/internal/quic/quic.js | 33 +++++++++++++++--- src/quic/defs.h | 1 + src/quic/http3.cc | 73 ++++++++++++++++++++++++++++----------- src/quic/session.h | 3 +- src/quic/streams.cc | 3 ++ 5 files changed, 87 insertions(+), 26 deletions(-) diff --git a/lib/internal/quic/quic.js b/lib/internal/quic/quic.js index d069e1958ccdfa..11cb1276ac3c9a 100644 --- a/lib/internal/quic/quic.js +++ b/lib/internal/quic/quic.js @@ -75,6 +75,7 @@ const { QUIC_STREAM_HEADERS_KIND_TRAILING: kHeadersKindTrailing, QUIC_STREAM_HEADERS_FLAGS_NONE: kHeadersFlagsNone, QUIC_STREAM_HEADERS_FLAGS_TERMINAL: kHeadersFlagsTerminal, + QUIC_STREAM_HEADERS_FLAGS_WEBTRANSPORT: kHeadersFlagsWebtransport, } = internalBinding('quic'); // Maps the numeric HeadersKind constants from C++ to user-facing strings. @@ -284,7 +285,9 @@ const endpointRegistry = new SafeSet(); * @property {string|ArrayBuffer|SharedArrayBuffer|ArrayBufferView|Blob| * FileHandle|AsyncIterable|Iterable|Promise|null} [body] The outbound * body source. See the public docs for `stream.setBody()` for details - * on supported types. When omitted, the stream is closed immediately. + * on supported types. When omitted, the stream is closed immediately, + * except if the stream is a webtransport stream. For a webtransport + * stream setting body is illegal. * @property {object} [headers] Initial request or response headers to * send. Only used when the negotiated application supports headers * (e.g. HTTP/3). @@ -292,6 +295,8 @@ const endpointRegistry = new SafeSet(); * @property {boolean} [incremental] Whether to interleave data with same-priority streams. * @property {number} [highWaterMark] The high water mark for write * backpressure, in bytes. **Default:** `65536`. + * @property {boolean} [webtransport] Indicates that the send headers signal + * webtransport support. If no headers are provided, it has no effect. * @property {OnHeadersCallback} [onheaders] Callback for incoming initial headers * @property {OnTrailersCallback} [ontrailers] Callback for incoming trailing headers * @property {OnInfoCallback} [oninfo] Callback for informational (1xx) headers @@ -501,6 +506,10 @@ const endpointRegistry = new SafeSet(); * @typedef {object} SendHeadersOptions * @property {boolean} [terminal] When true, indicates that no body data will be * sent after these headers. + * @property {boolean} [webtransport] When true, indicates that this is a header + * for a webtransport connection. Note, on the response, if you deny a + * webtransport connection, set it to false. A webtransport header can not be + * terminal. So we throw an error, if webtransport and terminal are both true. */ /** @@ -2027,10 +2036,15 @@ class QuicStream { 'The negotiated QUIC application protocol does not support headers'); } validateObject(headers, 'headers'); - const { terminal = false } = options; + const { terminal = false, webtransport = false } = options; + if (terminal && webtransport) { + throw new ERR_INVALID_ARG_VALUE( + 'webtransport and terminal can not be set simultaenously.'); + } const headerString = buildNgHeaderString( headers, assertValidPseudoHeader, true /* strictSingleValueFields */); - const flags = terminal ? kHeadersFlagsTerminal : kHeadersFlagsNone; + const flags = terminal ? kHeadersFlagsTerminal : + (webtransport ? kHeadersFlagsWebtransport : kHeadersFlagsNone); return this.#handle.sendHeaders(kHeadersKindInitial, headerString, flags); } @@ -3186,6 +3200,7 @@ class QuicSession { body, priority = 'default', incremental = false, + webtransport = false, highWaterMark = kDefaultHighWaterMark, headers, onheaders, @@ -3196,9 +3211,14 @@ class QuicSession { validateOneOf(priority, 'options.priority', ['default', 'low', 'high']); validateBoolean(incremental, 'options.incremental'); + validateBoolean(webtransport, 'options.webtransport'); const validatedBody = validateBody(body); + if (typeof body !== 'undefined' && webtransport) { + throw new ERR_INVALID_ARG_TYPE('options.body', 'A body can not be provided in webtransport mode'); + } + const handle = this.#handle.openStream(direction, validatedBody); if (handle === undefined) { throw new ERR_QUIC_OPEN_STREAM_FAILED(); @@ -3232,7 +3252,12 @@ class QuicSession { if (onwanttrailers) stream.onwanttrailers = onwanttrailers; if (headers !== undefined) { - stream.sendHeaders(headers, { terminal: validatedBody === undefined }); + stream.sendHeaders(headers, + { terminal: validatedBody === undefined && !webtransport, + webtransport }); + } else if (webtransport) { + throw new ERR_INVALID_ARG_VALUE('options.webtransport', + 'Specifying webtransport without a header has no effect'); } if (onSessionOpenStreamChannel.hasSubscribers) { diff --git a/src/quic/defs.h b/src/quic/defs.h index 75ae915335be93..d937469a41915d 100644 --- a/src/quic/defs.h +++ b/src/quic/defs.h @@ -309,6 +309,7 @@ enum class HeadersKind : uint8_t { enum class HeadersFlags : uint8_t { NONE, TERMINAL, + WEBTRANSPORT }; enum class StreamPriority : uint8_t { diff --git a/src/quic/http3.cc b/src/quic/http3.cc index e5118d318a3b69..2d80362c41000e 100644 --- a/src/quic/http3.cc +++ b/src/quic/http3.cc @@ -406,7 +406,8 @@ class Http3ApplicationImpl final : public Session::Application { WriteBE64(payload + 8, options_.qpack_max_dtable_capacity); WriteBE64(payload + 16, options_.qpack_encoder_max_dtable_capacity); WriteBE64(payload + 24, options_.qpack_blocked_streams); - payload[32] = options_.enable_connect_protocol ? 1 : 0; // May be bitfield should be used! + payload[32] = options_.enable_connect_protocol ? 1 : 0; + // May be bitfield should be used! payload[33] = options_.enable_datagrams ? 1 : 0; payload[34] = options_.enable_webtransport ? 1 : 0; @@ -592,33 +593,63 @@ class Http3ApplicationImpl final : public Session::Application { // If the terminal flag is set, that means that we know we're only // sending headers and no body and the stream writable side should be // closed immediately because there is no nghttp3_data_reader provided. - if (flags != HeadersFlags::TERMINAL) { + if (flags != HeadersFlags::TERMINAL + && flags != HeadersFlags::WEBTRANSPORT) { reader_ptr = &reader; } if (session().is_server()) { // If this is a server, we're submitting a response... - Debug(&session(), - "Submitting %" PRIu64 " response headers for stream %" PRIu64, - nva.length(), - stream.id()); - return nghttp3_conn_submit_response(*this, - stream.id(), - nva.data(), - nva.length(), - reader_ptr) == 0; + if (flags != HeadersFlags::WEBTRANSPORT) { + Debug(&session(), + "Submitting %" PRIu64 " response headers for stream %" PRIu64, + nva.length(), + stream.id()); + return nghttp3_conn_submit_response(*this, + stream.id(), + nva.data(), + nva.length(), + reader_ptr) == 0; + } else { + Debug(&session(), + "Submitting %" PRIu64 " wt resp. headers for stream %" PRIu64, + nva.length(), + stream.id()); + if (nghttp3_conn_submit_wt_response(*this, + stream.id(), + nva.data(), + nva.length()) != 0) + return false; + return nghttp3_conn_server_confirm_wt_session(*this, + stream.id(), + 0) == 0; + } } else { // Otherwise we're submitting a request... - Debug(&session(), - "Submitting %" PRIu64 " request headers for stream %" PRIu64, - nva.length(), - stream.id()); - return nghttp3_conn_submit_request(*this, - stream.id(), - nva.data(), - nva.length(), - reader_ptr, - const_cast(&stream)) == 0; + if (flags != HeadersFlags::WEBTRANSPORT) { + Debug(&session(), + "Submitting %" PRIu64 " request headers for stream %" PRIu64, + nva.length(), + stream.id()); + return nghttp3_conn_submit_request(*this, + stream.id(), + nva.data(), + nva.length(), + reader_ptr, + const_cast(&stream)) + == 0; + } else { + Debug(&session(), + "Submitting %" PRIu64 " wt req. headers for stream %" PRIu64, + nva.length(), + stream.id()); + return nghttp3_conn_submit_wt_request(*this, + stream.id(), + nva.data(), + nva.length(), + const_cast(&stream)) + == 0; + } } break; } diff --git a/src/quic/session.h b/src/quic/session.h index d0829ebe01b776..33a8289a622237 100644 --- a/src/quic/session.h +++ b/src/quic/session.h @@ -83,7 +83,8 @@ class Session final : public AsyncWrap, private SessionTicket::AppData::Source { bool enable_connect_protocol = true; bool enable_datagrams = true; - bool enable_webtransport = false; // for a client always enabling it, may be good + // for a client always enabling wt, may be good + bool enable_webtransport = false; operator const nghttp3_settings() const; diff --git a/src/quic/streams.cc b/src/quic/streams.cc index 7186aed89a78e9..dbedc44a1a6a6b 100644 --- a/src/quic/streams.cc +++ b/src/quic/streams.cc @@ -1089,6 +1089,8 @@ void Stream::InitPerContext(Realm* realm, Local target) { static_cast(HeadersFlags::NONE); constexpr int QUIC_STREAM_HEADERS_FLAGS_TERMINAL = static_cast(HeadersFlags::TERMINAL); + constexpr int QUIC_STREAM_HEADERS_FLAGS_WEBTRANSPORT = + static_cast(HeadersFlags::WEBTRANSPORT); NODE_DEFINE_CONSTANT(target, QUIC_STREAM_HEADERS_KIND_HINTS); NODE_DEFINE_CONSTANT(target, QUIC_STREAM_HEADERS_KIND_INITIAL); @@ -1096,6 +1098,7 @@ void Stream::InitPerContext(Realm* realm, Local target) { NODE_DEFINE_CONSTANT(target, QUIC_STREAM_HEADERS_FLAGS_NONE); NODE_DEFINE_CONSTANT(target, QUIC_STREAM_HEADERS_FLAGS_TERMINAL); + NODE_DEFINE_CONSTANT(target, QUIC_STREAM_HEADERS_FLAGS_WEBTRANSPORT); } Stream* Stream::From(void* stream_user_data) { From 76f2155bc26e8e36f07b6f147d54b873c723ed72 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Mon, 25 May 2026 09:16:35 +0200 Subject: [PATCH 07/10] quic: Improve webtransport options and lint --- lib/internal/quic/quic.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/internal/quic/quic.js b/lib/internal/quic/quic.js index 11cb1276ac3c9a..b8c7a70f62c65a 100644 --- a/lib/internal/quic/quic.js +++ b/lib/internal/quic/quic.js @@ -295,7 +295,7 @@ const endpointRegistry = new SafeSet(); * @property {boolean} [incremental] Whether to interleave data with same-priority streams. * @property {number} [highWaterMark] The high water mark for write * backpressure, in bytes. **Default:** `65536`. - * @property {boolean} [webtransport] Indicates that the send headers signal + * @property {boolean} [webtransport] Indicates that the headers to send signal * webtransport support. If no headers are provided, it has no effect. * @property {OnHeadersCallback} [onheaders] Callback for incoming initial headers * @property {OnTrailersCallback} [ontrailers] Callback for incoming trailing headers @@ -2039,7 +2039,8 @@ class QuicStream { const { terminal = false, webtransport = false } = options; if (terminal && webtransport) { throw new ERR_INVALID_ARG_VALUE( - 'webtransport and terminal can not be set simultaenously.'); + 'webtransport and terminal can not be set simultaenously.', + { terminal, webtransport }); } const headerString = buildNgHeaderString( headers, assertValidPseudoHeader, true /* strictSingleValueFields */); From 8199e16677c0b305f886ef10437466597e31d8e8 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Mon, 25 May 2026 14:31:03 +0200 Subject: [PATCH 08/10] quic: Implement callback for http/3 settings/application options --- doc/api/quic.md | 33 ++++++++++-- lib/internal/quic/diagnostics.js | 2 + lib/internal/quic/quic.js | 71 +++++++++++++++++++++++++ lib/internal/quic/symbols.js | 2 + src/quic/bindingdata.h | 1 + src/quic/http3.cc | 2 + src/quic/session.cc | 21 ++++++++ src/quic/session.h | 1 + test/parallel/test-quic-h3-settings.mjs | 4 ++ 9 files changed, 132 insertions(+), 5 deletions(-) diff --git a/doc/api/quic.md b/doc/api/quic.md index 5ecac022a3c83b..362ae4294c4799 100644 --- a/doc/api/quic.md +++ b/doc/api/quic.md @@ -1051,6 +1051,16 @@ added: v23.8.0 The endpoint that created this session. Returns `null` if the session has been destroyed. Read only. +### `session.onappliation` + + + +* Type: {quic.OnApplicationCallback} + +The callback to invoke when new application options, e.g. HTTP/3 settings arrived. + ### `session.onerror` + +* `applicationoptions` {quic.ApplicationOptions} Current application options. +* `session` {quic.QuicSession} + +Published when a locally-initiated stream is opened. + + ### Channel: `quic.session.created.client`