Skip to content

Commit beb9d2b

Browse files
deps: update nghttp3 to 1.17.0
PR-URL: #64182 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tim Perry <pimterry@gmail.com>
1 parent f96a639 commit beb9d2b

13 files changed

Lines changed: 4351 additions & 4265 deletions

deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,6 +2625,25 @@ NGHTTP3_EXTERN nghttp3_ssize nghttp3_conn_writev_stream(nghttp3_conn *conn,
26252625
NGHTTP3_EXTERN int nghttp3_conn_add_write_offset(nghttp3_conn *conn,
26262626
int64_t stream_id, size_t n);
26272627

2628+
/**
2629+
* @function
2630+
*
2631+
* `nghttp3_conn_is_stream_flushed` returns nonzero if all stream data
2632+
* for a stream identified by |stream_id| so far have been accepted by
2633+
* QUIC stack. This means that the cumulative number of bytes that
2634+
* `nghttp3_conn_add_write_offset` notified covers all stream data
2635+
* currently held. This does not mean more stream data cannot be
2636+
* submitted to this stream via :type:`nghttp3_read_data_callback` and
2637+
* all stream data have been acknowledged.
2638+
*
2639+
* If there is no stream identified by |stream_id|, this function
2640+
* returns nonzero.
2641+
*
2642+
* .. version-added:: 1.17.0
2643+
*/
2644+
NGHTTP3_EXTERN int nghttp3_conn_is_stream_flushed(const nghttp3_conn *conn,
2645+
int64_t stream_id);
2646+
26282647
/**
26292648
* @function
26302649
*
@@ -3418,6 +3437,75 @@ NGHTTP3_EXTERN const nghttp3_info *nghttp3_version(int least_version);
34183437
*/
34193438
NGHTTP3_EXTERN int nghttp3_err_is_fatal(int liberr);
34203439

3440+
/**
3441+
* @function
3442+
*
3443+
* `nghttp3_get_uvarint` reads variable-length unsigned integer from
3444+
* the buffer pointed by |p|, and stores it in the object pointed by
3445+
* |dest| in host byte order. It returns |p| plus the number of bytes
3446+
* read from |p|. This function assumes that |p| points to the buffer
3447+
* that contains a valid variable-length unsigned integer. Use
3448+
* `nghttp3_get_uvarintlen` to get the number of bytes to successfully
3449+
* decode an integer.
3450+
*
3451+
* .. version-added:: 1.17.0
3452+
*/
3453+
NGHTTP3_EXTERN const uint8_t *nghttp3_get_uvarint(uint64_t *dest,
3454+
const uint8_t *p);
3455+
3456+
/**
3457+
* @function
3458+
*
3459+
* `nghttp3_get_uvarintlen` returns the required number of bytes to
3460+
* read variable-length unsigned integer starting at |p|. |p| must
3461+
* not be NULL. This function only reads the single byte from the
3462+
* buffer pointed by |p|, and determines the number of bytes to read.
3463+
*
3464+
* .. version-added:: 1.17.0
3465+
*/
3466+
NGHTTP3_EXTERN size_t nghttp3_get_uvarintlen(const uint8_t *p);
3467+
3468+
/**
3469+
* @function
3470+
*
3471+
* `nghttp3_get_varint` reads variable-length unsigned integer from
3472+
* the buffer pointed by |p|, and stores it in the object pointed by
3473+
* |dest| in host byte order. It returns |p| plus the number of bytes
3474+
* read from |p|. This function assumes that |p| points to the buffer
3475+
* that contains a valid variable-length unsigned integer. Use
3476+
* `nghttp3_get_uvarintlen` to get the number of bytes to successfully
3477+
* decode an integer.
3478+
*
3479+
* .. version-added:: 1.17.0
3480+
*/
3481+
NGHTTP3_EXTERN const uint8_t *nghttp3_get_varint(int64_t *dest,
3482+
const uint8_t *p);
3483+
3484+
/**
3485+
* @function
3486+
*
3487+
* `nghttp3_put_uvarint` writes |n| to the buffer pointed by |p| using
3488+
* variable-length unsigned integer encoding. It returns the one
3489+
* beyond of the last written position. This function assumes that
3490+
* the buffer pointed by |p| has sufficient capacity to encode |n|.
3491+
* To know the required capacity, use `nghttp3_put_uvarintlen`. |n|
3492+
* must be less than or equal to (1 << 62) - 1.
3493+
*
3494+
* .. version-added:: 1.17.0
3495+
*/
3496+
NGHTTP3_EXTERN uint8_t *nghttp3_put_uvarint(uint8_t *p, uint64_t n);
3497+
3498+
/**
3499+
* @function
3500+
*
3501+
* `nghttp3_put_uvarintlen` returns the required number of bytes to
3502+
* encode |n| in variable-length unsigned integer encoding. |n| must
3503+
* be less than or equal to (1 << 62) - 1.
3504+
*
3505+
* .. version-added:: 1.17.0
3506+
*/
3507+
NGHTTP3_EXTERN size_t nghttp3_put_uvarintlen(uint64_t n);
3508+
34213509
/*
34223510
* Versioned function wrappers
34233511
*/

deps/ngtcp2/nghttp3/lib/includes/nghttp3/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
* Version number of the nghttp3 library release.
3333
*/
34-
#define NGHTTP3_VERSION "1.16.0"
34+
#define NGHTTP3_VERSION "1.17.0"
3535

3636
/**
3737
* @macro
@@ -41,6 +41,6 @@
4141
* number, 8 bits for minor and 8 bits for patch. Version 1.2.3
4242
* becomes 0x010203.
4343
*/
44-
#define NGHTTP3_VERSION_NUM 0x011000
44+
#define NGHTTP3_VERSION_NUM 0x011100
4545

4646
#endif /* !defined(NGHTTP3_VERSION_H) */

deps/ngtcp2/nghttp3/lib/nghttp3_conn.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2979,3 +2979,25 @@ int nghttp3_conn_is_drained2(const nghttp3_conn *conn) {
29792979
nghttp3_stream_outq_write_done(conn->tx.ctrl) &&
29802980
nghttp3_ringbuf_len(&conn->tx.ctrl->frq) == 0;
29812981
}
2982+
2983+
int nghttp3_conn_is_stream_flushed(const nghttp3_conn *conn,
2984+
int64_t stream_id) {
2985+
nghttp3_stream *stream = nghttp3_conn_find_stream(conn, stream_id);
2986+
const nghttp3_frame *fr;
2987+
2988+
if (!stream) {
2989+
return 1;
2990+
}
2991+
2992+
if (!nghttp3_stream_outq_write_done(stream)) {
2993+
return 0;
2994+
}
2995+
2996+
if (nghttp3_ringbuf_len(&stream->frq) == 0) {
2997+
return 1;
2998+
}
2999+
3000+
fr = nghttp3_ringbuf_get(&stream->frq, 0);
3001+
3002+
return fr->hd.type == NGHTTP3_FRAME_DATA;
3003+
}

deps/ngtcp2/nghttp3/lib/nghttp3_conv.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ size_t nghttp3_get_uvarintlen(const uint8_t *p) {
7070
return (size_t)(1U << (*p >> 6));
7171
}
7272

73+
const uint8_t *nghttp3_get_varint(int64_t *dest, const uint8_t *p) {
74+
uint64_t n;
75+
76+
p = nghttp3_get_uvarint(&n, p);
77+
*dest = (int64_t)n;
78+
79+
return p;
80+
}
81+
7382
uint8_t *nghttp3_put_uint64be(uint8_t *p, uint64_t n) {
7483
n = nghttp3_htonl64(n);
7584
return nghttp3_cpymem(p, (const uint8_t *)&n, sizeof(n));

deps/ngtcp2/nghttp3/lib/nghttp3_conv.h

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -92,34 +92,6 @@
9292
# define ntohs(N) _byteswap_ushort(N)
9393
#endif /* defined(WIN32) */
9494

95-
/*
96-
* nghttp3_get_uvarint reads variable-length unsigned integer from
97-
* |p|, and stores it in the buffer pointed by |dest| in host byte
98-
* order. It returns |p| plus the number of bytes read from |p|.
99-
*/
100-
const uint8_t *nghttp3_get_uvarint(uint64_t *dest, const uint8_t *p);
101-
102-
/*
103-
* nghttp3_get_uvarintlen returns the required number of bytes to read
104-
* variable-length integer starting at |p|.
105-
*/
106-
size_t nghttp3_get_uvarintlen(const uint8_t *p);
107-
108-
/*
109-
* nghttp3_get_varint reads variable-length unsigned integer from |p|,
110-
* and stores it in the buffer pointed by |dest| in host byte order.
111-
* It returns |p| plus the number of bytes read from |p|.
112-
*/
113-
static inline const uint8_t *nghttp3_get_varint(int64_t *dest,
114-
const uint8_t *p) {
115-
uint64_t n;
116-
117-
p = nghttp3_get_uvarint(&n, p);
118-
*dest = (int64_t)n;
119-
120-
return p;
121-
}
122-
12395
/*
12496
* nghttp3_put_uint64be writes |n| in host byte order in |p| in
12597
* network byte order. It returns the one beyond of the last written
@@ -141,18 +113,6 @@ uint8_t *nghttp3_put_uint32be(uint8_t *p, uint32_t n);
141113
*/
142114
uint8_t *nghttp3_put_uint16be(uint8_t *p, uint16_t n);
143115

144-
/*
145-
* nghttp3_put_uvarint writes |n| in |p| using variable-length integer
146-
* encoding. It returns the one beyond of the last written position.
147-
*/
148-
uint8_t *nghttp3_put_uvarint(uint8_t *p, uint64_t n);
149-
150-
/*
151-
* nghttp3_put_uvarintlen returns the required number of bytes to
152-
* encode |n|.
153-
*/
154-
size_t nghttp3_put_uvarintlen(uint64_t n);
155-
156116
/*
157117
* nghttp3_ord_stream_id returns the ordinal number of |stream_id|.
158118
*/

deps/ngtcp2/nghttp3/lib/nghttp3_http.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@
3636
#include "nghttp3_macro.h"
3737
#include "nghttp3_conv.h"
3838
#include "nghttp3_unreachable.h"
39+
#include "nghttp3_str.h"
3940
#include "sfparse/sfparse.h"
4041

41-
static uint8_t downcase(uint8_t c) {
42-
return 'A' <= c && c <= 'Z' ? (uint8_t)(c - 'A' + 'a') : c;
43-
}
44-
4542
/*
4643
* memieq returns 1 if the data pointed by |a| of length |n| equals to
4744
* |b| of the same length in case-insensitive manner. The data
@@ -52,7 +49,7 @@ static int memieq(const void *a, const void *b, size_t n) {
5249
const uint8_t *aa = a, *bb = b;
5350

5451
for (i = 0; i < n; ++i) {
55-
if (aa[i] != downcase(bb[i])) {
52+
if (aa[i] != nghttp3_downcase_byte(bb[i])) {
5653
return 0;
5754
}
5855
}
@@ -704,7 +701,7 @@ int nghttp3_check_header_name(const uint8_t *name, size_t len) {
704701
--len;
705702
}
706703
for (last = name + len; name != last; ++name) {
707-
if (!VALID_HD_NAME_CHARS[*name]) {
704+
if (VALID_HD_NAME_CHARS[*name] != 1) {
708705
return 0;
709706
}
710707
}

deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ uint8_t *nghttp3_qpack_huffman_encode(uint8_t *dest, const uint8_t *src,
8080
void nghttp3_qpack_huffman_decode_context_init(
8181
nghttp3_qpack_huffman_decode_context *ctx) {
8282
*ctx = (nghttp3_qpack_huffman_decode_context){
83-
.flags = NGHTTP3_QPACK_HUFFMAN_ACCEPTED,
83+
.flags = NGHTTP3_QPACK_HUFFMAN_FLAG_ACCEPTED,
8484
};
8585
}
8686

@@ -103,20 +103,20 @@ nghttp3_qpack_huffman_decode(nghttp3_qpack_huffman_decode_context *ctx,
103103
for (; src != end;) {
104104
c = *src++;
105105
t = qpack_huffman_decode_table[t.fstate][c >> 4];
106-
if (t.flags & NGHTTP3_QPACK_HUFFMAN_SYM) {
106+
if (t.flags & NGHTTP3_QPACK_HUFFMAN_FLAG_SYM) {
107107
*p++ = t.sym;
108108
}
109109

110110
t = qpack_huffman_decode_table[t.fstate][c & 0xFU];
111-
if (t.flags & NGHTTP3_QPACK_HUFFMAN_SYM) {
111+
if (t.flags & NGHTTP3_QPACK_HUFFMAN_FLAG_SYM) {
112112
*p++ = t.sym;
113113
}
114114
}
115115

116116
ctx->fstate = t.fstate;
117117
ctx->flags = t.flags;
118118

119-
if (fin && !(ctx->flags & NGHTTP3_QPACK_HUFFMAN_ACCEPTED)) {
119+
if (fin && !(ctx->flags & NGHTTP3_QPACK_HUFFMAN_FLAG_ACCEPTED)) {
120120
return NGHTTP3_ERR_QPACK_FATAL;
121121
}
122122

deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,24 @@ size_t nghttp3_qpack_huffman_encode_count(const uint8_t *src, size_t len);
4646
uint8_t *nghttp3_qpack_huffman_encode(uint8_t *dest, const uint8_t *src,
4747
size_t srclen);
4848

49-
typedef enum nghttp3_qpack_huffman_decode_flag {
50-
/* FSA accepts this state as the end of huffman encoding
51-
sequence. */
52-
NGHTTP3_QPACK_HUFFMAN_ACCEPTED = 1,
53-
/* This state emits symbol */
54-
NGHTTP3_QPACK_HUFFMAN_SYM = 1 << 1,
55-
} nghttp3_qpack_huffman_decode_flag;
49+
/* NGHTTP3_QPACK_HUFFMAN_FLAG_ACCEPTED indicates that FSA accepts this
50+
state as the end of huffman encoding sequence. */
51+
#define NGHTTP3_QPACK_HUFFMAN_FLAG_ACCEPTED 0x01U
52+
/* NGHTTP3_QPACK_HUFFMAN_FLAG_SYM indicates that this state emits
53+
symbol */
54+
#define NGHTTP3_QPACK_HUFFMAN_FLAG_SYM 0x02U
5655

5756
typedef struct nghttp3_qpack_huffman_decode_node {
5857
/* fstate is the current huffman decoding state, which is actually
5958
the node ID of internal huffman tree with
60-
nghttp3_qpack_huffman_decode_flag OR-ed. We have 257 leaf nodes,
61-
but they are identical to root node other than emitting a symbol,
62-
so we have 256 internal nodes [1..256], inclusive. The node ID
63-
256 is a special node and it is a terminal state that means
64-
decoding failed. */
59+
NGHTTP3_QPACK_HUFFMAN_FLAG_* flags OR-ed. We have 257 leaf
60+
nodes, but they are identical to root node other than emitting a
61+
symbol, so we have 256 internal nodes [1..256], inclusive. The
62+
node ID 256 is a special node and it is a terminal state that
63+
means decoding failed. */
6564
uint16_t fstate;
6665
uint8_t flags;
67-
/* symbol if NGHTTP3_QPACK_HUFFMAN_SYM flag set */
66+
/* symbol if NGHTTP3_QPACK_HUFFMAN_FLAG_SYM flag set */
6867
uint8_t sym;
6968
} nghttp3_qpack_huffman_decode_node;
7069

0 commit comments

Comments
 (0)