| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2625,6 +2625,25 @@ NGHTTP3_EXTERN nghttp3_ssize nghttp3_conn_writev_stream(nghttp3_conn *conn, | |||
| 2625 | 2625 | NGHTTP3_EXTERN int nghttp3_conn_add_write_offset(nghttp3_conn *conn, | |
| 2626 | 2626 | int64_t stream_id, size_t n); | |
| 2627 | 2627 | ||
| 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 | + | ||
| 2628 | 2647 | /** | |
| 2629 | 2648 | * @function | |
| 2630 | 2649 | * | |
@@ -3418,6 +3437,75 @@ NGHTTP3_EXTERN const nghttp3_info *nghttp3_version(int least_version); | |||
| 3418 | 3437 | */ | |
| 3419 | 3438 | NGHTTP3_EXTERN int nghttp3_err_is_fatal(int liberr); | |
| 3420 | 3439 | ||
| 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 | + | ||
| 3421 | 3509 | /* | |
| 3422 | 3510 | * Versioned function wrappers | |
| 3423 | 3511 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ | |||
| 31 | 31 | * | |
| 32 | 32 | * Version number of the nghttp3 library release. | |
| 33 | 33 | */ | |
| 34 | - #define NGHTTP3_VERSION "1.16.0" | ||
| 34 | + #define NGHTTP3_VERSION "1.17.0" | ||
| 35 | 35 | ||
| 36 | 36 | /** | |
| 37 | 37 | * @macro | |
@@ -41,6 +41,6 @@ | |||
| 41 | 41 | * number, 8 bits for minor and 8 bits for patch. Version 1.2.3 | |
| 42 | 42 | * becomes 0x010203. | |
| 43 | 43 | */ | |
| 44 | - #define NGHTTP3_VERSION_NUM 0x011000 | ||
| 44 | + #define NGHTTP3_VERSION_NUM 0x011100 | ||
| 45 | 45 | ||
| 46 | 46 | #endif /* !defined(NGHTTP3_VERSION_H) */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2979,3 +2979,25 @@ int nghttp3_conn_is_drained2(const nghttp3_conn *conn) { | |||
| 2979 | 2979 | nghttp3_stream_outq_write_done(conn->tx.ctrl) && | |
| 2980 | 2980 | nghttp3_ringbuf_len(&conn->tx.ctrl->frq) == 0; | |
| 2981 | 2981 | } | |
| 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 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -70,6 +70,15 @@ size_t nghttp3_get_uvarintlen(const uint8_t *p) { | |||
| 70 | 70 | return (size_t)(1U << (*p >> 6)); | |
| 71 | 71 | } | |
| 72 | 72 | ||
| 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 | + | ||
| 73 | 82 | uint8_t *nghttp3_put_uint64be(uint8_t *p, uint64_t n) { | |
| 74 | 83 | n = nghttp3_htonl64(n); | |
| 75 | 84 | return nghttp3_cpymem(p, (const uint8_t *)&n, sizeof(n)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,34 +92,6 @@ | |||
| 92 | 92 | # define ntohs(N) _byteswap_ushort(N) | |
| 93 | 93 | #endif /* defined(WIN32) */ | |
| 94 | 94 | ||
| 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 | - | ||
| 123 | 95 | /* | |
| 124 | 96 | * nghttp3_put_uint64be writes |n| in host byte order in |p| in | |
| 125 | 97 | * 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); | |||
| 141 | 113 | */ | |
| 142 | 114 | uint8_t *nghttp3_put_uint16be(uint8_t *p, uint16_t n); | |
| 143 | 115 | ||
| 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 | - | ||
| 156 | 116 | /* | |
| 157 | 117 | * nghttp3_ord_stream_id returns the ordinal number of |stream_id|. | |
| 158 | 118 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,12 +36,9 @@ | |||
| 36 | 36 | #include "nghttp3_macro.h" | |
| 37 | 37 | #include "nghttp3_conv.h" | |
| 38 | 38 | #include "nghttp3_unreachable.h" | |
| 39 | + #include "nghttp3_str.h" | ||
| 39 | 40 | #include "sfparse/sfparse.h" | |
| 40 | 41 | ||
| 41 | - static uint8_t downcase(uint8_t c) { | ||
| 42 | - return 'A' <= c && c <= 'Z' ? (uint8_t)(c - 'A' + 'a') : c; | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | 42 | /* | |
| 46 | 43 | * memieq returns 1 if the data pointed by |a| of length |n| equals to | |
| 47 | 44 | * |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) { | |||
| 52 | 49 | const uint8_t *aa = a, *bb = b; | |
| 53 | 50 | ||
| 54 | 51 | for (i = 0; i < n; ++i) { | |
| 55 | - if (aa[i] != downcase(bb[i])) { | ||
| 52 | + if (aa[i] != nghttp3_downcase_byte(bb[i])) { | ||
| 56 | 53 | return 0; | |
| 57 | 54 | } | |
| 58 | 55 | } | |
@@ -704,7 +701,7 @@ int nghttp3_check_header_name(const uint8_t *name, size_t len) { | |||
| 704 | 701 | --len; | |
| 705 | 702 | } | |
| 706 | 703 | for (last = name + len; name != last; ++name) { | |
| 707 | - if (!VALID_HD_NAME_CHARS[*name]) { | ||
| 704 | + if (VALID_HD_NAME_CHARS[*name] != 1) { | ||
| 708 | 705 | return 0; | |
| 709 | 706 | } | |
| 710 | 707 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -80,7 +80,7 @@ uint8_t *nghttp3_qpack_huffman_encode(uint8_t *dest, const uint8_t *src, | |||
| 80 | 80 | void nghttp3_qpack_huffman_decode_context_init( | |
| 81 | 81 | nghttp3_qpack_huffman_decode_context *ctx) { | |
| 82 | 82 | *ctx = (nghttp3_qpack_huffman_decode_context){ | |
| 83 | - .flags = NGHTTP3_QPACK_HUFFMAN_ACCEPTED, | ||
| 83 | + .flags = NGHTTP3_QPACK_HUFFMAN_FLAG_ACCEPTED, | ||
| 84 | 84 | }; | |
| 85 | 85 | } | |
| 86 | 86 | ||
@@ -103,20 +103,20 @@ nghttp3_qpack_huffman_decode(nghttp3_qpack_huffman_decode_context *ctx, | |||
| 103 | 103 | for (; src != end;) { | |
| 104 | 104 | c = *src++; | |
| 105 | 105 | 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) { | ||
| 107 | 107 | *p++ = t.sym; | |
| 108 | 108 | } | |
| 109 | 109 | ||
| 110 | 110 | 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) { | ||
| 112 | 112 | *p++ = t.sym; | |
| 113 | 113 | } | |
| 114 | 114 | } | |
| 115 | 115 | ||
| 116 | 116 | ctx->fstate = t.fstate; | |
| 117 | 117 | ctx->flags = t.flags; | |
| 118 | 118 | ||
| 119 | - if (fin && !(ctx->flags & NGHTTP3_QPACK_HUFFMAN_ACCEPTED)) { | ||
| 119 | + if (fin && !(ctx->flags & NGHTTP3_QPACK_HUFFMAN_FLAG_ACCEPTED)) { | ||
| 120 | 120 | return NGHTTP3_ERR_QPACK_FATAL; | |
| 121 | 121 | } | |
| 122 | 122 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,25 +46,24 @@ size_t nghttp3_qpack_huffman_encode_count(const uint8_t *src, size_t len); | |||
| 46 | 46 | uint8_t *nghttp3_qpack_huffman_encode(uint8_t *dest, const uint8_t *src, | |
| 47 | 47 | size_t srclen); | |
| 48 | 48 | ||
| 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 | ||
| 56 | 55 | ||
| 57 | 56 | typedef struct nghttp3_qpack_huffman_decode_node { | |
| 58 | 57 | /* fstate is the current huffman decoding state, which is actually | |
| 59 | 58 | 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. */ | ||
| 65 | 64 | uint16_t fstate; | |
| 66 | 65 | uint8_t flags; | |
| 67 | - /* symbol if NGHTTP3_QPACK_HUFFMAN_SYM flag set */ | ||
| 66 | + /* symbol if NGHTTP3_QPACK_HUFFMAN_FLAG_SYM flag set */ | ||
| 68 | 67 | uint8_t sym; | |
| 69 | 68 | } nghttp3_qpack_huffman_decode_node; | |
| 70 | 69 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments