Skip to content

Commit 7b6d2a8

Browse files
anonrigdanielleadams
authored andcommittedJan 3, 2023
deps: update nghttp2 to 1.51.0
PR-URL: #45537 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 20f6fa3 commit 7b6d2a8

27 files changed

+2190
-101
lines changed
 

‎deps/nghttp2/lib/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ set(NGHTTP2_SOURCES
2323
nghttp2_mem.c
2424
nghttp2_http.c
2525
nghttp2_rcbuf.c
26+
nghttp2_extpri.c
2627
nghttp2_debug.c
2728
)
2829

‎deps/nghttp2/lib/Makefile.am

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ OBJECTS = nghttp2_pq.c nghttp2_map.c nghttp2_queue.c \
5050
nghttp2_mem.c \
5151
nghttp2_http.c \
5252
nghttp2_rcbuf.c \
53+
nghttp2_extpri.c \
5354
nghttp2_debug.c
5455

5556
HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \
@@ -66,6 +67,7 @@ HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \
6667
nghttp2_mem.h \
6768
nghttp2_http.h \
6869
nghttp2_rcbuf.h \
70+
nghttp2_extpri.h \
6971
nghttp2_debug.h
7072

7173
libnghttp2_la_SOURCES = $(HFILES) $(OBJECTS)

‎deps/nghttp2/lib/Makefile.in

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Makefile.in generated by automake 1.16.4 from Makefile.am.
1+
# Makefile.in generated by automake 1.16.5 from Makefile.am.
22
# @configure_input@
33

44
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
@@ -162,7 +162,7 @@ am__objects_2 = nghttp2_pq.lo nghttp2_map.lo nghttp2_queue.lo \
162162
nghttp2_hd_huffman.lo nghttp2_hd_huffman_data.lo \
163163
nghttp2_version.lo nghttp2_priority_spec.lo nghttp2_option.lo \
164164
nghttp2_callbacks.lo nghttp2_mem.lo nghttp2_http.lo \
165-
nghttp2_rcbuf.lo nghttp2_debug.lo
165+
nghttp2_rcbuf.lo nghttp2_extpri.lo nghttp2_debug.lo
166166
am_libnghttp2_la_OBJECTS = $(am__objects_1) $(am__objects_2)
167167
libnghttp2_la_OBJECTS = $(am_libnghttp2_la_OBJECTS)
168168
AM_V_lt = $(am__v_lt_@AM_V@)
@@ -189,8 +189,9 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp
189189
am__maybe_remake_depfiles = depfiles
190190
am__depfiles_remade = ./$(DEPDIR)/nghttp2_buf.Plo \
191191
./$(DEPDIR)/nghttp2_callbacks.Plo \
192-
./$(DEPDIR)/nghttp2_debug.Plo ./$(DEPDIR)/nghttp2_frame.Plo \
193-
./$(DEPDIR)/nghttp2_hd.Plo ./$(DEPDIR)/nghttp2_hd_huffman.Plo \
192+
./$(DEPDIR)/nghttp2_debug.Plo ./$(DEPDIR)/nghttp2_extpri.Plo \
193+
./$(DEPDIR)/nghttp2_frame.Plo ./$(DEPDIR)/nghttp2_hd.Plo \
194+
./$(DEPDIR)/nghttp2_hd_huffman.Plo \
194195
./$(DEPDIR)/nghttp2_hd_huffman_data.Plo \
195196
./$(DEPDIR)/nghttp2_helper.Plo ./$(DEPDIR)/nghttp2_http.Plo \
196197
./$(DEPDIR)/nghttp2_map.Plo ./$(DEPDIR)/nghttp2_mem.Plo \
@@ -336,6 +337,7 @@ EXTRABPFCFLAGS = @EXTRABPFCFLAGS@
336337
EXTRACFLAG = @EXTRACFLAG@
337338
EXTRA_DEFS = @EXTRA_DEFS@
338339
FGREP = @FGREP@
340+
FILECMD = @FILECMD@
339341
GREP = @GREP@
340342
HAVE_CXX14 = @HAVE_CXX14@
341343
INSTALL = @INSTALL@
@@ -523,6 +525,7 @@ OBJECTS = nghttp2_pq.c nghttp2_map.c nghttp2_queue.c \
523525
nghttp2_mem.c \
524526
nghttp2_http.c \
525527
nghttp2_rcbuf.c \
528+
nghttp2_extpri.c \
526529
nghttp2_debug.c
527530

528531
HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \
@@ -539,6 +542,7 @@ HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \
539542
nghttp2_mem.h \
540543
nghttp2_http.h \
541544
nghttp2_rcbuf.h \
545+
nghttp2_extpri.h \
542546
nghttp2_debug.h
543547

544548
libnghttp2_la_SOURCES = $(HFILES) $(OBJECTS)
@@ -628,6 +632,7 @@ distclean-compile:
628632
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_buf.Plo@am__quote@ # am--include-marker
629633
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_callbacks.Plo@am__quote@ # am--include-marker
630634
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_debug.Plo@am__quote@ # am--include-marker
635+
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_extpri.Plo@am__quote@ # am--include-marker
631636
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_frame.Plo@am__quote@ # am--include-marker
632637
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_hd.Plo@am__quote@ # am--include-marker
633638
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_hd_huffman.Plo@am__quote@ # am--include-marker
@@ -909,6 +914,7 @@ distclean: distclean-recursive
909914
-rm -f ./$(DEPDIR)/nghttp2_buf.Plo
910915
-rm -f ./$(DEPDIR)/nghttp2_callbacks.Plo
911916
-rm -f ./$(DEPDIR)/nghttp2_debug.Plo
917+
-rm -f ./$(DEPDIR)/nghttp2_extpri.Plo
912918
-rm -f ./$(DEPDIR)/nghttp2_frame.Plo
913919
-rm -f ./$(DEPDIR)/nghttp2_hd.Plo
914920
-rm -f ./$(DEPDIR)/nghttp2_hd_huffman.Plo
@@ -976,6 +982,7 @@ maintainer-clean: maintainer-clean-recursive
976982
-rm -f ./$(DEPDIR)/nghttp2_buf.Plo
977983
-rm -f ./$(DEPDIR)/nghttp2_callbacks.Plo
978984
-rm -f ./$(DEPDIR)/nghttp2_debug.Plo
985+
-rm -f ./$(DEPDIR)/nghttp2_extpri.Plo
979986
-rm -f ./$(DEPDIR)/nghttp2_frame.Plo
980987
-rm -f ./$(DEPDIR)/nghttp2_hd.Plo
981988
-rm -f ./$(DEPDIR)/nghttp2_hd_huffman.Plo

‎deps/nghttp2/lib/includes/Makefile.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Makefile.in generated by automake 1.16.4 from Makefile.am.
1+
# Makefile.in generated by automake 1.16.5 from Makefile.am.
22
# @configure_input@
33

44
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
@@ -245,6 +245,7 @@ EXTRABPFCFLAGS = @EXTRABPFCFLAGS@
245245
EXTRACFLAG = @EXTRACFLAG@
246246
EXTRA_DEFS = @EXTRA_DEFS@
247247
FGREP = @FGREP@
248+
FILECMD = @FILECMD@
248249
GREP = @GREP@
249250
HAVE_CXX14 = @HAVE_CXX14@
250251
INSTALL = @INSTALL@

‎deps/nghttp2/lib/includes/nghttp2/nghttp2.h

+241-8
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,11 @@ typedef enum {
634634
* The ORIGIN frame, which is defined by `RFC 8336
635635
* <https://tools.ietf.org/html/rfc8336>`_.
636636
*/
637-
NGHTTP2_ORIGIN = 0x0c
637+
NGHTTP2_ORIGIN = 0x0c,
638+
/**
639+
* The PRIORITY_UPDATE frame, which is defined by :rfc:`9218`.
640+
*/
641+
NGHTTP2_PRIORITY_UPDATE = 0x10
638642
} nghttp2_frame_type;
639643

640644
/**
@@ -703,7 +707,11 @@ typedef enum {
703707
* SETTINGS_ENABLE_CONNECT_PROTOCOL
704708
* (`RFC 8441 <https://tools.ietf.org/html/rfc8441>`_)
705709
*/
706-
NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL = 0x08
710+
NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL = 0x08,
711+
/**
712+
* SETTINGS_NO_RFC7540_PRIORITIES (:rfc:`9218`)
713+
*/
714+
NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES = 0x09
707715
} nghttp2_settings_id;
708716
/* Note: If we add SETTINGS, update the capacity of
709717
NGHTTP2_INBOUND_NUM_IV as well */
@@ -1422,12 +1430,6 @@ typedef ssize_t (*nghttp2_recv_callback)(nghttp2_session *session, uint8_t *buf,
14221430
* respectively. The header name/value pairs are emitted via
14231431
* :type:`nghttp2_on_header_callback`.
14241432
*
1425-
* For HEADERS, PUSH_PROMISE and DATA frames, this callback may be
1426-
* called after stream is closed (see
1427-
* :type:`nghttp2_on_stream_close_callback`). The application should
1428-
* check that stream is still alive using its own stream management or
1429-
* :func:`nghttp2_session_get_stream_user_data()`.
1430-
*
14311433
* Only HEADERS and DATA frame can signal the end of incoming data.
14321434
* If ``frame->hd.flags & NGHTTP2_FLAG_END_STREAM`` is nonzero, the
14331435
* |frame| is the last frame from the remote peer in this stream.
@@ -2693,6 +2695,11 @@ nghttp2_option_set_max_deflate_dynamic_table_size(nghttp2_option *option,
26932695
* This option prevents the library from retaining closed streams to
26942696
* maintain the priority tree. If this option is set to nonzero,
26952697
* applications can discard closed stream completely to save memory.
2698+
*
2699+
* If
2700+
* :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES`
2701+
* of value of 1 is submitted via `nghttp2_submit_settings()`, any
2702+
* closed streams are not retained regardless of this option.
26962703
*/
26972704
NGHTTP2_EXTERN void nghttp2_option_set_no_closed_streams(nghttp2_option *option,
26982705
int val);
@@ -2719,6 +2726,36 @@ NGHTTP2_EXTERN void nghttp2_option_set_max_outbound_ack(nghttp2_option *option,
27192726
NGHTTP2_EXTERN void nghttp2_option_set_max_settings(nghttp2_option *option,
27202727
size_t val);
27212728

2729+
/**
2730+
* @function
2731+
*
2732+
* This option, if set to nonzero, allows server to fallback to
2733+
* :rfc:`7540` priorities if SETTINGS_NO_RFC7540_PRIORITIES was not
2734+
* received from client, and server submitted
2735+
* :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES`
2736+
* = 1 via `nghttp2_submit_settings()`. Most of the advanced
2737+
* functionality for RFC 7540 priorities are still disabled. This
2738+
* fallback only enables the minimal feature set of RFC 7540
2739+
* priorities to deal with priority signaling from client.
2740+
*
2741+
* Client session ignores this option.
2742+
*/
2743+
NGHTTP2_EXTERN void
2744+
nghttp2_option_set_server_fallback_rfc7540_priorities(nghttp2_option *option,
2745+
int val);
2746+
2747+
/**
2748+
* @function
2749+
*
2750+
* This option, if set to nonzero, turns off RFC 9113 leading and
2751+
* trailing white spaces validation against HTTP field value. Some
2752+
* important fields, such as HTTP/2 pseudo header fields, are
2753+
* validated more strictly and this option does not apply to them.
2754+
*/
2755+
NGHTTP2_EXTERN void
2756+
nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation(
2757+
nghttp2_option *option, int val);
2758+
27222759
/**
27232760
* @function
27242761
*
@@ -3589,6 +3626,11 @@ NGHTTP2_EXTERN int nghttp2_session_consume_stream(nghttp2_session *session,
35893626
* found, we use default priority instead of given |pri_spec|. That
35903627
* is make stream depend on root stream with weight 16.
35913628
*
3629+
* If
3630+
* :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES`
3631+
* of value of 1 is submitted via `nghttp2_submit_settings()`, this
3632+
* function does nothing and returns 0.
3633+
*
35923634
* This function returns 0 if it succeeds, or one of the following
35933635
* negative error codes:
35943636
*
@@ -3632,6 +3674,11 @@ nghttp2_session_change_stream_priority(nghttp2_session *session,
36323674
* found, we use default priority instead of given |pri_spec|. That
36333675
* is make stream depend on root stream with weight 16.
36343676
*
3677+
* If
3678+
* :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES`
3679+
* of value of 1 is submitted via `nghttp2_submit_settings()`, this
3680+
* function does nothing and returns 0.
3681+
*
36353682
* This function returns 0 if it succeeds, or one of the following
36363683
* negative error codes:
36373684
*
@@ -3837,6 +3884,11 @@ nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec);
38373884
* :macro:`NGHTTP2_MAX_WEIGHT`, it becomes
38383885
* :macro:`NGHTTP2_MAX_WEIGHT`.
38393886
*
3887+
* If
3888+
* :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES`
3889+
* of value of 1 is received by a remote endpoint, |pri_spec| is
3890+
* ignored, and treated as if ``NULL`` is specified.
3891+
*
38403892
* The |nva| is an array of name/value pair :type:`nghttp2_nv` with
38413893
* |nvlen| elements. The application is responsible to include
38423894
* required pseudo-header fields (header field whose name starts with
@@ -4057,6 +4109,11 @@ NGHTTP2_EXTERN int nghttp2_submit_trailer(nghttp2_session *session,
40574109
* :macro:`NGHTTP2_MIN_WEIGHT`. If it is strictly greater than
40584110
* :macro:`NGHTTP2_MAX_WEIGHT`, it becomes :macro:`NGHTTP2_MAX_WEIGHT`.
40594111
*
4112+
* If
4113+
* :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES`
4114+
* of value of 1 is received by a remote endpoint, |pri_spec| is
4115+
* ignored, and treated as if ``NULL`` is specified.
4116+
*
40604117
* The |nva| is an array of name/value pair :type:`nghttp2_nv` with
40614118
* |nvlen| elements. The application is responsible to include
40624119
* required pseudo-header fields (header field whose name starts with
@@ -4184,6 +4241,11 @@ NGHTTP2_EXTERN int nghttp2_submit_data(nghttp2_session *session, uint8_t flags,
41844241
* :macro:`NGHTTP2_MAX_WEIGHT`, it becomes
41854242
* :macro:`NGHTTP2_MAX_WEIGHT`.
41864243
*
4244+
* If
4245+
* :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES`
4246+
* of value of 1 is received by a remote endpoint, this function does
4247+
* nothing and returns 0.
4248+
*
41874249
* This function returns 0 if it succeeds, or one of the following
41884250
* negative error codes:
41894251
*
@@ -4198,6 +4260,61 @@ nghttp2_submit_priority(nghttp2_session *session, uint8_t flags,
41984260
int32_t stream_id,
41994261
const nghttp2_priority_spec *pri_spec);
42004262

4263+
/**
4264+
* @macro
4265+
*
4266+
* :macro:`NGHTTP2_EXTPRI_DEFAULT_URGENCY` is the default urgency
4267+
* level for :rfc:`9218` extensible priorities.
4268+
*/
4269+
#define NGHTTP2_EXTPRI_DEFAULT_URGENCY 3
4270+
4271+
/**
4272+
* @macro
4273+
*
4274+
* :macro:`NGHTTP2_EXTPRI_URGENCY_HIGH` is the highest urgency level
4275+
* for :rfc:`9218` extensible priorities.
4276+
*/
4277+
#define NGHTTP2_EXTPRI_URGENCY_HIGH 0
4278+
4279+
/**
4280+
* @macro
4281+
*
4282+
* :macro:`NGHTTP2_EXTPRI_URGENCY_LOW` is the lowest urgency level for
4283+
* :rfc:`9218` extensible priorities.
4284+
*/
4285+
#define NGHTTP2_EXTPRI_URGENCY_LOW 7
4286+
4287+
/**
4288+
* @macro
4289+
*
4290+
* :macro:`NGHTTP2_EXTPRI_URGENCY_LEVELS` is the number of urgency
4291+
* levels for :rfc:`9218` extensible priorities.
4292+
*/
4293+
#define NGHTTP2_EXTPRI_URGENCY_LEVELS (NGHTTP2_EXTPRI_URGENCY_LOW + 1)
4294+
4295+
/**
4296+
* @struct
4297+
*
4298+
* :type:`nghttp2_extpri` is :rfc:`9218` extensible priorities
4299+
* specification for a stream.
4300+
*/
4301+
typedef struct nghttp2_extpri {
4302+
/**
4303+
* :member:`urgency` is the urgency of a stream, it must be in
4304+
* [:macro:`NGHTTP2_EXTPRI_URGENCY_HIGH`,
4305+
* :macro:`NGHTTP2_EXTPRI_URGENCY_LOW`], inclusive, and 0 is the
4306+
* highest urgency.
4307+
*/
4308+
uint32_t urgency;
4309+
/**
4310+
* :member:`inc` indicates that a content can be processed
4311+
* incrementally or not. If inc is 0, it cannot be processed
4312+
* incrementally. If inc is 1, it can be processed incrementally.
4313+
* Other value is not permitted.
4314+
*/
4315+
int inc;
4316+
} nghttp2_extpri;
4317+
42014318
/**
42024319
* @function
42034320
*
@@ -4722,6 +4839,108 @@ NGHTTP2_EXTERN int nghttp2_submit_origin(nghttp2_session *session,
47224839
const nghttp2_origin_entry *ov,
47234840
size_t nov);
47244841

4842+
/**
4843+
* @struct
4844+
*
4845+
* The payload of PRIORITY_UPDATE frame. PRIORITY_UPDATE frame is a
4846+
* non-critical extension to HTTP/2. If this frame is received, and
4847+
* `nghttp2_option_set_user_recv_extension_type()` is not set, and
4848+
* `nghttp2_option_set_builtin_recv_extension_type()` is set for
4849+
* :enum:`nghttp2_frame_type.NGHTTP2_PRIORITY_UPDATE`,
4850+
* ``nghttp2_extension.payload`` will point to this struct.
4851+
*
4852+
* It has the following members:
4853+
*/
4854+
typedef struct {
4855+
/**
4856+
* The stream ID of the stream whose priority is updated.
4857+
*/
4858+
int32_t stream_id;
4859+
/**
4860+
* The pointer to Priority field value. It is not necessarily
4861+
* NULL-terminated.
4862+
*/
4863+
uint8_t *field_value;
4864+
/**
4865+
* The length of the :member:`field_value`.
4866+
*/
4867+
size_t field_value_len;
4868+
} nghttp2_ext_priority_update;
4869+
4870+
/**
4871+
* @function
4872+
*
4873+
* Submits PRIORITY_UPDATE frame.
4874+
*
4875+
* PRIORITY_UPDATE frame is a non-critical extension to HTTP/2, and
4876+
* defined in :rfc:`9218#section-7.1`.
4877+
*
4878+
* The |flags| is currently ignored and should be
4879+
* :enum:`nghttp2_flag.NGHTTP2_FLAG_NONE`.
4880+
*
4881+
* The |stream_id| is the ID of stream which is prioritized. The
4882+
* |field_value| points to the Priority field value. The
4883+
* |field_value_len| is the length of the Priority field value.
4884+
*
4885+
* If this function is called by server,
4886+
* :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE` is returned.
4887+
*
4888+
* If
4889+
* :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES`
4890+
* of value of 0 is received by a remote endpoint (or it is omitted),
4891+
* this function does nothing and returns 0.
4892+
*
4893+
* This function returns 0 if it succeeds, or one of the following
4894+
* negative error codes:
4895+
*
4896+
* :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM`
4897+
* Out of memory
4898+
* :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`
4899+
* The function is called from server side session
4900+
* :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT`
4901+
* The |field_value_len| is larger than 16380; or |stream_id| is
4902+
* 0.
4903+
*/
4904+
NGHTTP2_EXTERN int nghttp2_submit_priority_update(nghttp2_session *session,
4905+
uint8_t flags,
4906+
int32_t stream_id,
4907+
const uint8_t *field_value,
4908+
size_t field_value_len);
4909+
4910+
/**
4911+
* @function
4912+
*
4913+
* Changes the priority of the existing stream denoted by |stream_id|.
4914+
* The new priority is |extpri|. This function is meant to be used by
4915+
* server for :rfc:`9218` extensible prioritization scheme.
4916+
*
4917+
* If |session| is initialized as client, this function returns
4918+
* :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`. For client, use
4919+
* `nghttp2_submit_priority_update()` instead.
4920+
*
4921+
* If :member:`extpri->urgency <nghttp2_extpri.urgency>` is out of
4922+
* bound, it is set to :macro:`NGHTTP2_EXTPRI_URGENCY_LOW`.
4923+
*
4924+
* If |ignore_client_signal| is nonzero, server starts to ignore
4925+
* client priority signals for this stream.
4926+
*
4927+
* If
4928+
* :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES`
4929+
* of value of 1 is not submitted via `nghttp2_submit_settings()`,
4930+
* this function does nothing and returns 0.
4931+
*
4932+
* :enum:`nghttp2_error.NGHTTP2_ERR_NOMEM`
4933+
* Out of memory.
4934+
* :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`
4935+
* The |session| is initialized as client.
4936+
* :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT`
4937+
* |stream_id| is zero; or a stream denoted by |stream_id| is not
4938+
* found.
4939+
*/
4940+
NGHTTP2_EXTERN int nghttp2_session_change_extpri_stream_priority(
4941+
nghttp2_session *session, int32_t stream_id, const nghttp2_extpri *extpri,
4942+
int ignore_client_signal);
4943+
47254944
/**
47264945
* @function
47274946
*
@@ -4833,9 +5052,23 @@ NGHTTP2_EXTERN int nghttp2_check_header_name(const uint8_t *name, size_t len);
48335052
* Returns nonzero if HTTP header field value |value| of length |len|
48345053
* is valid according to
48355054
* http://tools.ietf.org/html/rfc7230#section-3.2
5055+
*
5056+
* This function is considered obsolete, and application should
5057+
* consider to use `nghttp2_check_header_value_rfc9113()` instead.
48365058
*/
48375059
NGHTTP2_EXTERN int nghttp2_check_header_value(const uint8_t *value, size_t len);
48385060

5061+
/**
5062+
* @function
5063+
*
5064+
* Returns nonzero if HTTP header field value |value| of length |len|
5065+
* is valid according to
5066+
* http://tools.ietf.org/html/rfc7230#section-3.2, plus
5067+
* https://datatracker.ietf.org/doc/html/rfc9113#section-8.2.1
5068+
*/
5069+
NGHTTP2_EXTERN int nghttp2_check_header_value_rfc9113(const uint8_t *value,
5070+
size_t len);
5071+
48395072
/**
48405073
* @function
48415074
*

‎deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
* @macro
3030
* Version number of the nghttp2 library release
3131
*/
32-
#define NGHTTP2_VERSION "1.47.0"
32+
#define NGHTTP2_VERSION "1.51.0"
3333

3434
/**
3535
* @macro
3636
* Numerical representation of the version number of the nghttp2 library
3737
* release. This is a 24 bit number with 8 bits for major number, 8 bits
3838
* for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203.
3939
*/
40-
#define NGHTTP2_VERSION_NUM 0x012f00
40+
#define NGHTTP2_VERSION_NUM 0x013300
4141

4242
#endif /* NGHTTP2VER_H */

‎deps/nghttp2/lib/nghttp2_extpri.c

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* nghttp2 - HTTP/2 C Library
3+
*
4+
* Copyright (c) 2022 nghttp3 contributors
5+
* Copyright (c) 2022 nghttp2 contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining
8+
* a copy of this software and associated documentation files (the
9+
* "Software"), to deal in the Software without restriction, including
10+
* without limitation the rights to use, copy, modify, merge, publish,
11+
* distribute, sublicense, and/or sell copies of the Software, and to
12+
* permit persons to whom the Software is furnished to do so, subject to
13+
* the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be
16+
* included in all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25+
*/
26+
#include "nghttp2_extpri.h"
27+
28+
uint8_t nghttp2_extpri_to_uint8(const nghttp2_extpri *extpri) {
29+
return (uint8_t)((uint32_t)extpri->inc << 7 | extpri->urgency);
30+
}
31+
32+
void nghttp2_extpri_from_uint8(nghttp2_extpri *extpri, uint8_t u8extpri) {
33+
extpri->urgency = nghttp2_extpri_uint8_urgency(u8extpri);
34+
extpri->inc = nghttp2_extpri_uint8_inc(u8extpri);
35+
}

‎deps/nghttp2/lib/nghttp2_extpri.h

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* nghttp2 - HTTP/2 C Library
3+
*
4+
* Copyright (c) 2022 nghttp3 contributors
5+
* Copyright (c) 2022 nghttp2 contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining
8+
* a copy of this software and associated documentation files (the
9+
* "Software"), to deal in the Software without restriction, including
10+
* without limitation the rights to use, copy, modify, merge, publish,
11+
* distribute, sublicense, and/or sell copies of the Software, and to
12+
* permit persons to whom the Software is furnished to do so, subject to
13+
* the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be
16+
* included in all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25+
*/
26+
#ifndef NGHTTP2_EXTPRI_H
27+
#define NGHTTP2_EXTPRI_H
28+
29+
#ifdef HAVE_CONFIG_H
30+
# include <config.h>
31+
#endif /* HAVE_CONFIG_H */
32+
33+
#include <nghttp2/nghttp2.h>
34+
35+
/*
36+
* NGHTTP2_EXTPRI_INC_MASK is a bit mask to retrieve incremental bit
37+
* from a value produced by nghttp2_extpri_to_uint8.
38+
*/
39+
#define NGHTTP2_EXTPRI_INC_MASK (1 << 7)
40+
41+
/*
42+
* nghttp2_extpri_to_uint8 encodes |pri| into uint8_t variable.
43+
*/
44+
uint8_t nghttp2_extpri_to_uint8(const nghttp2_extpri *extpri);
45+
46+
/*
47+
* nghttp2_extpri_from_uint8 decodes |u8extpri|, which is produced by
48+
* nghttp2_extpri_to_uint8, intto |extpri|.
49+
*/
50+
void nghttp2_extpri_from_uint8(nghttp2_extpri *extpri, uint8_t u8extpri);
51+
52+
/*
53+
* nghttp2_extpri_uint8_urgency extracts urgency from |PRI| which is
54+
* supposed to be constructed by nghttp2_extpri_to_uint8.
55+
*/
56+
#define nghttp2_extpri_uint8_urgency(PRI) \
57+
((uint32_t)((PRI) & ~NGHTTP2_EXTPRI_INC_MASK))
58+
59+
/*
60+
* nghttp2_extpri_uint8_inc extracts inc from |PRI| which is supposed to
61+
* be constructed by nghttp2_extpri_to_uint8.
62+
*/
63+
#define nghttp2_extpri_uint8_inc(PRI) (((PRI)&NGHTTP2_EXTPRI_INC_MASK) != 0)
64+
65+
#endif /* NGHTTP2_EXTPRI_H */

‎deps/nghttp2/lib/nghttp2_frame.c

+81
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,31 @@ void nghttp2_frame_origin_free(nghttp2_extension *frame, nghttp2_mem *mem) {
253253
nghttp2_mem_free(mem, origin->ov);
254254
}
255255

256+
void nghttp2_frame_priority_update_init(nghttp2_extension *frame,
257+
int32_t stream_id, uint8_t *field_value,
258+
size_t field_value_len) {
259+
nghttp2_ext_priority_update *priority_update;
260+
261+
nghttp2_frame_hd_init(&frame->hd, 4 + field_value_len,
262+
NGHTTP2_PRIORITY_UPDATE, NGHTTP2_FLAG_NONE, 0);
263+
264+
priority_update = frame->payload;
265+
priority_update->stream_id = stream_id;
266+
priority_update->field_value = field_value;
267+
priority_update->field_value_len = field_value_len;
268+
}
269+
270+
void nghttp2_frame_priority_update_free(nghttp2_extension *frame,
271+
nghttp2_mem *mem) {
272+
nghttp2_ext_priority_update *priority_update;
273+
274+
priority_update = frame->payload;
275+
if (priority_update == NULL) {
276+
return;
277+
}
278+
nghttp2_mem_free(mem, priority_update->field_value);
279+
}
280+
256281
size_t nghttp2_frame_priority_len(uint8_t flags) {
257282
if (flags & NGHTTP2_FLAG_PRIORITY) {
258283
return NGHTTP2_PRIORITY_SPECLEN;
@@ -876,6 +901,57 @@ int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame,
876901
return 0;
877902
}
878903

904+
int nghttp2_frame_pack_priority_update(nghttp2_bufs *bufs,
905+
nghttp2_extension *frame) {
906+
int rv;
907+
nghttp2_buf *buf;
908+
nghttp2_ext_priority_update *priority_update;
909+
910+
/* This is required with --disable-assert. */
911+
(void)rv;
912+
913+
priority_update = frame->payload;
914+
915+
buf = &bufs->head->buf;
916+
917+
assert(nghttp2_buf_avail(buf) >= 4 + priority_update->field_value_len);
918+
919+
buf->pos -= NGHTTP2_FRAME_HDLEN;
920+
921+
nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
922+
923+
nghttp2_put_uint32be(buf->last, (uint32_t)priority_update->stream_id);
924+
buf->last += 4;
925+
926+
rv = nghttp2_bufs_add(bufs, priority_update->field_value,
927+
priority_update->field_value_len);
928+
929+
assert(rv == 0);
930+
931+
return 0;
932+
}
933+
934+
void nghttp2_frame_unpack_priority_update_payload(nghttp2_extension *frame,
935+
uint8_t *payload,
936+
size_t payloadlen) {
937+
nghttp2_ext_priority_update *priority_update;
938+
939+
assert(payloadlen >= 4);
940+
941+
priority_update = frame->payload;
942+
943+
priority_update->stream_id =
944+
nghttp2_get_uint32(payload) & NGHTTP2_STREAM_ID_MASK;
945+
946+
if (payloadlen > 4) {
947+
priority_update->field_value = payload + 4;
948+
priority_update->field_value_len = payloadlen - 4;
949+
} else {
950+
priority_update->field_value = NULL;
951+
priority_update->field_value_len = 0;
952+
}
953+
}
954+
879955
nghttp2_settings_entry *nghttp2_frame_iv_copy(const nghttp2_settings_entry *iv,
880956
size_t niv, nghttp2_mem *mem) {
881957
nghttp2_settings_entry *iv_copy;
@@ -1071,6 +1147,11 @@ int nghttp2_iv_check(const nghttp2_settings_entry *iv, size_t niv) {
10711147
return 0;
10721148
}
10731149
break;
1150+
case NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES:
1151+
if (iv[i].value != 0 && iv[i].value != 1) {
1152+
return 0;
1153+
}
1154+
break;
10741155
}
10751156
}
10761157
return 1;

‎deps/nghttp2/lib/nghttp2_frame.h

+45
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
typedef union {
7474
nghttp2_ext_altsvc altsvc;
7575
nghttp2_ext_origin origin;
76+
nghttp2_ext_priority_update priority_update;
7677
} nghttp2_ext_frame_payload;
7778

7879
void nghttp2_frame_pack_frame_hd(uint8_t *buf, const nghttp2_frame_hd *hd);
@@ -423,6 +424,31 @@ int nghttp2_frame_pack_origin(nghttp2_bufs *bufs, nghttp2_extension *ext);
423424
int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame,
424425
const uint8_t *payload,
425426
size_t payloadlen, nghttp2_mem *mem);
427+
428+
/*
429+
* Packs PRIORITY_UPDATE frame |frame| in wire frame format and store
430+
* it in |bufs|.
431+
*
432+
* The caller must make sure that nghttp2_bufs_reset(bufs) is called
433+
* before calling this function.
434+
*
435+
* This function always succeeds and returns 0.
436+
*/
437+
int nghttp2_frame_pack_priority_update(nghttp2_bufs *bufs,
438+
nghttp2_extension *ext);
439+
440+
/*
441+
* Unpacks PRIORITY_UPDATE wire format into |frame|. The |payload| of
442+
* |payloadlen| bytes contains frame payload. This function assumes
443+
* that frame->payload points to the nghttp2_ext_priority_update
444+
* object.
445+
*
446+
* This function always succeeds and returns 0.
447+
*/
448+
void nghttp2_frame_unpack_priority_update_payload(nghttp2_extension *frame,
449+
uint8_t *payload,
450+
size_t payloadlen);
451+
426452
/*
427453
* Initializes HEADERS frame |frame| with given values. |frame| takes
428454
* ownership of |nva|, so caller must not free it. If |stream_id| is
@@ -538,6 +564,25 @@ void nghttp2_frame_origin_init(nghttp2_extension *frame,
538564
*/
539565
void nghttp2_frame_origin_free(nghttp2_extension *frame, nghttp2_mem *mem);
540566

567+
/*
568+
* Initializes PRIORITY_UPDATE frame |frame| with given values. This
569+
* function assumes that frame->payload points to
570+
* nghttp2_ext_priority_update object. On success, this function
571+
* takes ownership of |field_value|, so caller must not free it.
572+
*/
573+
void nghttp2_frame_priority_update_init(nghttp2_extension *frame,
574+
int32_t stream_id, uint8_t *field_value,
575+
size_t field_value_len);
576+
577+
/*
578+
* Frees up resources under |frame|. This function does not free
579+
* nghttp2_ext_priority_update object pointed by frame->payload. This
580+
* function only frees field_value pointed by
581+
* nghttp2_ext_priority_update.field_value.
582+
*/
583+
void nghttp2_frame_priority_update_free(nghttp2_extension *frame,
584+
nghttp2_mem *mem);
585+
541586
/*
542587
* Returns the number of padding bytes after payload. The total
543588
* padding length is given in the |padlen|. The returned value does

‎deps/nghttp2/lib/nghttp2_hd.c

+5
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ static int32_t lookup_token(const uint8_t *name, size_t namelen) {
269269
return NGHTTP2_TOKEN_LOCATION;
270270
}
271271
break;
272+
case 'y':
273+
if (memeq("priorit", name, 7)) {
274+
return NGHTTP2_TOKEN_PRIORITY;
275+
}
276+
break;
272277
}
273278
break;
274279
case 9:

‎deps/nghttp2/lib/nghttp2_hd.h

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ typedef enum {
112112
NGHTTP2_TOKEN_PROXY_CONNECTION,
113113
NGHTTP2_TOKEN_UPGRADE,
114114
NGHTTP2_TOKEN__PROTOCOL,
115+
NGHTTP2_TOKEN_PRIORITY,
115116
} nghttp2_token;
116117

117118
struct nghttp2_hd_entry;

‎deps/nghttp2/lib/nghttp2_helper.c

+13
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,19 @@ int nghttp2_check_header_value(const uint8_t *value, size_t len) {
507507
return 1;
508508
}
509509

510+
int nghttp2_check_header_value_rfc9113(const uint8_t *value, size_t len) {
511+
if (len == 0) {
512+
return 1;
513+
}
514+
515+
if (*value == ' ' || *value == '\t' || *(value + len - 1) == ' ' ||
516+
*(value + len - 1) == '\t') {
517+
return 0;
518+
}
519+
520+
return nghttp2_check_header_value(value, len);
521+
}
522+
510523
/* Generated by genmethodchartbl.py */
511524
static char VALID_METHOD_CHARS[] = {
512525
0 /* NUL */, 0 /* SOH */, 0 /* STX */, 0 /* ETX */,

‎deps/nghttp2/lib/nghttp2_http.c

+774-22
Large diffs are not rendered by default.

‎deps/nghttp2/lib/nghttp2_http.h

+51
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,55 @@ int nghttp2_http_on_data_chunk(nghttp2_stream *stream, size_t n);
9494
void nghttp2_http_record_request_method(nghttp2_stream *stream,
9595
nghttp2_frame *frame);
9696

97+
/*
98+
* RFC 8941 Structured Field Values.
99+
*/
100+
typedef enum nghttp2_sf_value_type {
101+
NGHTTP2_SF_VALUE_TYPE_BOOLEAN,
102+
NGHTTP2_SF_VALUE_TYPE_INTEGER,
103+
NGHTTP2_SF_VALUE_TYPE_DECIMAL,
104+
NGHTTP2_SF_VALUE_TYPE_STRING,
105+
NGHTTP2_SF_VALUE_TYPE_TOKEN,
106+
NGHTTP2_SF_VALUE_TYPE_BYTESEQ,
107+
NGHTTP2_SF_VALUE_TYPE_INNER_LIST,
108+
} nghttp2_sf_value_type;
109+
110+
/*
111+
* nghttp2_sf_value stores Structured Field Values item. For Inner
112+
* List, only type is set to NGHTTP2_SF_VALUE_TYPE_INNER_LIST.
113+
*/
114+
typedef struct nghttp2_sf_value {
115+
uint8_t type;
116+
union {
117+
int b;
118+
int64_t i;
119+
double d;
120+
struct {
121+
const uint8_t *base;
122+
size_t len;
123+
} s;
124+
};
125+
} nghttp2_sf_value;
126+
127+
/*
128+
* nghttp2_sf_parse_item parses the input sequence [|begin|, |end|)
129+
* and stores the parsed an Item in |dest|. It returns the number of
130+
* bytes consumed if it succeeds, or -1. This function is declared
131+
* here for unit tests.
132+
*/
133+
ssize_t nghttp2_sf_parse_item(nghttp2_sf_value *dest, const uint8_t *begin,
134+
const uint8_t *end);
135+
136+
/*
137+
* nghttp2_sf_parse_inner_list parses the input sequence [|begin|, |end|)
138+
* and stores the parsed an Inner List in |dest|. It returns the number of
139+
* bytes consumed if it succeeds, or -1. This function is declared
140+
* here for unit tests.
141+
*/
142+
ssize_t nghttp2_sf_parse_inner_list(nghttp2_sf_value *dest,
143+
const uint8_t *begin, const uint8_t *end);
144+
145+
int nghttp2_http_parse_priority(nghttp2_extpri *dest, const uint8_t *value,
146+
size_t valuelen);
147+
97148
#endif /* NGHTTP2_HTTP_H */

‎deps/nghttp2/lib/nghttp2_net.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
STIN uint32_t htonl(uint32_t hostlong) {
5454
uint32_t res;
5555
unsigned char *p = (unsigned char *)&res;
56-
*p++ = hostlong >> 24;
56+
*p++ = (unsigned char)(hostlong >> 24);
5757
*p++ = (hostlong >> 16) & 0xffu;
5858
*p++ = (hostlong >> 8) & 0xffu;
5959
*p = hostlong & 0xffu;
@@ -63,25 +63,25 @@ STIN uint32_t htonl(uint32_t hostlong) {
6363
STIN uint16_t htons(uint16_t hostshort) {
6464
uint16_t res;
6565
unsigned char *p = (unsigned char *)&res;
66-
*p++ = hostshort >> 8;
66+
*p++ = (unsigned char)(hostshort >> 8);
6767
*p = hostshort & 0xffu;
6868
return res;
6969
}
7070

7171
STIN uint32_t ntohl(uint32_t netlong) {
7272
uint32_t res;
7373
unsigned char *p = (unsigned char *)&netlong;
74-
res = *p++ << 24;
75-
res += *p++ << 16;
76-
res += *p++ << 8;
74+
res = (uint32_t)(*p++ << 24);
75+
res += (uint32_t)(*p++ << 16);
76+
res += (uint32_t)(*p++ << 8);
7777
res += *p;
7878
return res;
7979
}
8080

8181
STIN uint16_t ntohs(uint16_t netshort) {
8282
uint16_t res;
8383
unsigned char *p = (unsigned char *)&netshort;
84-
res = *p++ << 8;
84+
res = (uint16_t)(*p++ << 8);
8585
res += *p;
8686
return res;
8787
}

‎deps/nghttp2/lib/nghttp2_option.c

+17
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ void nghttp2_option_set_builtin_recv_extension_type(nghttp2_option *option,
9090
option->opt_set_mask |= NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES;
9191
option->builtin_recv_ext_types |= NGHTTP2_TYPEMASK_ORIGIN;
9292
return;
93+
case NGHTTP2_PRIORITY_UPDATE:
94+
option->opt_set_mask |= NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES;
95+
option->builtin_recv_ext_types |= NGHTTP2_TYPEMASK_PRIORITY_UPDATE;
96+
return;
9397
default:
9498
return;
9599
}
@@ -126,3 +130,16 @@ void nghttp2_option_set_max_settings(nghttp2_option *option, size_t val) {
126130
option->opt_set_mask |= NGHTTP2_OPT_MAX_SETTINGS;
127131
option->max_settings = val;
128132
}
133+
134+
void nghttp2_option_set_server_fallback_rfc7540_priorities(
135+
nghttp2_option *option, int val) {
136+
option->opt_set_mask |= NGHTTP2_OPT_SERVER_FALLBACK_RFC7540_PRIORITIES;
137+
option->server_fallback_rfc7540_priorities = val;
138+
}
139+
140+
void nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation(
141+
nghttp2_option *option, int val) {
142+
option->opt_set_mask |=
143+
NGHTTP2_OPT_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION;
144+
option->no_rfc9113_leading_and_trailing_ws_validation = val;
145+
}

‎deps/nghttp2/lib/nghttp2_option.h

+10
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ typedef enum {
6868
NGHTTP2_OPT_NO_CLOSED_STREAMS = 1 << 10,
6969
NGHTTP2_OPT_MAX_OUTBOUND_ACK = 1 << 11,
7070
NGHTTP2_OPT_MAX_SETTINGS = 1 << 12,
71+
NGHTTP2_OPT_SERVER_FALLBACK_RFC7540_PRIORITIES = 1 << 13,
72+
NGHTTP2_OPT_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION = 1 << 14,
7173
} nghttp2_option_flag;
7274

7375
/**
@@ -127,6 +129,14 @@ struct nghttp2_option {
127129
* NGHTTP2_OPT_NO_CLOSED_STREAMS
128130
*/
129131
int no_closed_streams;
132+
/**
133+
* NGHTTP2_OPT_SERVER_FALLBACK_RFC7540_PRIORITIES
134+
*/
135+
int server_fallback_rfc7540_priorities;
136+
/**
137+
* NGHTTP2_OPT_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION
138+
*/
139+
int no_rfc9113_leading_and_trailing_ws_validation;
130140
/**
131141
* NGHTTP2_OPT_USER_RECV_EXT_TYPES
132142
*/

‎deps/nghttp2/lib/nghttp2_outbound_item.c

+3
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ void nghttp2_outbound_item_free(nghttp2_outbound_item *item, nghttp2_mem *mem) {
8989
case NGHTTP2_ORIGIN:
9090
nghttp2_frame_origin_free(&frame->ext, mem);
9191
break;
92+
case NGHTTP2_PRIORITY_UPDATE:
93+
nghttp2_frame_priority_update_free(&frame->ext, mem);
94+
break;
9295
default:
9396
assert(0);
9497
break;

‎deps/nghttp2/lib/nghttp2_pq.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@
2929

3030
#include "nghttp2_helper.h"
3131

32-
int nghttp2_pq_init(nghttp2_pq *pq, nghttp2_less less, nghttp2_mem *mem) {
32+
void nghttp2_pq_init(nghttp2_pq *pq, nghttp2_less less, nghttp2_mem *mem) {
3333
pq->mem = mem;
3434
pq->capacity = 0;
3535
pq->q = NULL;
3636
pq->length = 0;
3737
pq->less = less;
38-
return 0;
3938
}
4039

4140
void nghttp2_pq_free(nghttp2_pq *pq) {

‎deps/nghttp2/lib/nghttp2_pq.h

+1-7
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,8 @@ typedef struct {
5555

5656
/*
5757
* Initializes priority queue |pq| with compare function |cmp|.
58-
*
59-
* This function returns 0 if it succeeds, or one of the following
60-
* negative error codes:
61-
*
62-
* NGHTTP2_ERR_NOMEM
63-
* Out of memory.
6458
*/
65-
int nghttp2_pq_init(nghttp2_pq *pq, nghttp2_less less, nghttp2_mem *mem);
59+
void nghttp2_pq_init(nghttp2_pq *pq, nghttp2_less less, nghttp2_mem *mem);
6660

6761
/*
6862
* Deallocates any resources allocated for |pq|. The stored items are

‎deps/nghttp2/lib/nghttp2_session.c

+668-38
Large diffs are not rendered by default.

‎deps/nghttp2/lib/nghttp2_session.h

+35-6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ typedef enum {
5252
NGHTTP2_OPTMASK_NO_RECV_CLIENT_MAGIC = 1 << 1,
5353
NGHTTP2_OPTMASK_NO_HTTP_MESSAGING = 1 << 2,
5454
NGHTTP2_OPTMASK_NO_AUTO_PING_ACK = 1 << 3,
55-
NGHTTP2_OPTMASK_NO_CLOSED_STREAMS = 1 << 4
55+
NGHTTP2_OPTMASK_NO_CLOSED_STREAMS = 1 << 4,
56+
NGHTTP2_OPTMASK_SERVER_FALLBACK_RFC7540_PRIORITIES = 1 << 5,
57+
NGHTTP2_OPTMASK_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION = 1 << 6,
5658
} nghttp2_optmask;
5759

5860
/*
@@ -62,7 +64,8 @@ typedef enum {
6264
typedef enum {
6365
NGHTTP2_TYPEMASK_NONE = 0,
6466
NGHTTP2_TYPEMASK_ALTSVC = 1 << 0,
65-
NGHTTP2_TYPEMASK_ORIGIN = 1 << 1
67+
NGHTTP2_TYPEMASK_ORIGIN = 1 << 1,
68+
NGHTTP2_TYPEMASK_PRIORITY_UPDATE = 1 << 2
6669
} nghttp2_typemask;
6770

6871
typedef enum {
@@ -151,10 +154,8 @@ typedef struct {
151154
/* padding length for the current frame */
152155
size_t padlen;
153156
nghttp2_inbound_state state;
154-
/* Small buffer. Currently the largest contiguous chunk to buffer
155-
is frame header. We buffer part of payload, but they are smaller
156-
than frame header. */
157-
uint8_t raw_sbuf[NGHTTP2_FRAME_HDLEN];
157+
/* Small fixed sized buffer. */
158+
uint8_t raw_sbuf[32];
158159
} nghttp2_inbound_frame;
159160

160161
typedef struct {
@@ -165,6 +166,7 @@ typedef struct {
165166
uint32_t max_frame_size;
166167
uint32_t max_header_list_size;
167168
uint32_t enable_connect_protocol;
169+
uint32_t no_rfc7540_priorities;
168170
} nghttp2_settings_storage;
169171

170172
typedef enum {
@@ -202,6 +204,12 @@ struct nghttp2_session {
202204
response) frame, which are subject to
203205
SETTINGS_MAX_CONCURRENT_STREAMS limit. */
204206
nghttp2_outbound_queue ob_syn;
207+
/* Queues for DATA frames which is used when
208+
SETTINGS_NO_RFC7540_PRIORITIES is enabled. This implements RFC
209+
9218 extensible prioritization scheme. */
210+
struct {
211+
nghttp2_pq ob_data;
212+
} sched[NGHTTP2_EXTPRI_URGENCY_LEVELS];
205213
nghttp2_active_outbound_item aob;
206214
nghttp2_inbound_frame iframe;
207215
nghttp2_hd_deflater hd_deflater;
@@ -227,6 +235,9 @@ struct nghttp2_session {
227235
/* Queue of In-flight SETTINGS values. SETTINGS bearing ACK is not
228236
considered as in-flight. */
229237
nghttp2_inflight_settings *inflight_settings_head;
238+
/* Sequential number across all streams to process streams in
239+
FIFO. */
240+
uint64_t stream_seq;
230241
/* The number of outgoing streams. This will be capped by
231242
remote_settings.max_concurrent_streams. */
232243
size_t num_outgoing_streams;
@@ -328,6 +339,11 @@ struct nghttp2_session {
328339
/* Unacked local ENABLE_CONNECT_PROTOCOL value. We use this to
329340
accept :protocol header field before SETTINGS_ACK is received. */
330341
uint8_t pending_enable_connect_protocol;
342+
/* Unacked local SETTINGS_NO_RFC7540_PRIORITIES value, which is
343+
effective before it is acknowledged. */
344+
uint8_t pending_no_rfc7540_priorities;
345+
/* Turn on fallback to RFC 7540 priorities; for server use only. */
346+
uint8_t fallback_rfc7540_priorities;
331347
/* Nonzero if the session is server side. */
332348
uint8_t server;
333349
/* Flags indicating GOAWAY is sent and/or received. The flags are
@@ -773,6 +789,19 @@ int nghttp2_session_on_altsvc_received(nghttp2_session *session,
773789
int nghttp2_session_on_origin_received(nghttp2_session *session,
774790
nghttp2_frame *frame);
775791

792+
/*
793+
* Called when PRIORITY_UPDATE is received, assuming |frame| is
794+
* properly initialized.
795+
*
796+
* This function returns 0 if it succeeds, or one of the following
797+
* negative error codes:
798+
*
799+
* NGHTTP2_ERR_CALLBACK_FAILURE
800+
* The callback function failed.
801+
*/
802+
int nghttp2_session_on_priority_update_received(nghttp2_session *session,
803+
nghttp2_frame *frame);
804+
776805
/*
777806
* Called when DATA is received, assuming |frame| is properly
778807
* initialized.

‎deps/nghttp2/lib/nghttp2_stream.c

+18
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ void nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id,
100100
stream->descendant_next_seq = 0;
101101
stream->seq = 0;
102102
stream->last_writelen = 0;
103+
104+
stream->extpri = stream->http_extpri = NGHTTP2_EXTPRI_DEFAULT_URGENCY;
103105
}
104106

105107
void nghttp2_stream_free(nghttp2_stream *stream) {
@@ -484,6 +486,10 @@ int nghttp2_stream_attach_item(nghttp2_stream *stream,
484486

485487
stream->item = item;
486488

489+
if (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) {
490+
return 0;
491+
}
492+
487493
rv = stream_update_dep_on_attach_item(stream);
488494
if (rv != 0) {
489495
/* This may relave stream->queued == 1, but stream->item == NULL.
@@ -503,6 +509,10 @@ int nghttp2_stream_detach_item(nghttp2_stream *stream) {
503509
stream->item = NULL;
504510
stream->flags = (uint8_t)(stream->flags & ~NGHTTP2_STREAM_FLAG_DEFERRED_ALL);
505511

512+
if (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) {
513+
return 0;
514+
}
515+
506516
return stream_update_dep_on_detach_item(stream);
507517
}
508518

@@ -514,6 +524,10 @@ int nghttp2_stream_defer_item(nghttp2_stream *stream, uint8_t flags) {
514524

515525
stream->flags |= flags;
516526

527+
if (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) {
528+
return 0;
529+
}
530+
517531
return stream_update_dep_on_detach_item(stream);
518532
}
519533

@@ -529,6 +543,10 @@ int nghttp2_stream_resume_deferred_item(nghttp2_stream *stream, uint8_t flags) {
529543
return 0;
530544
}
531545

546+
if (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) {
547+
return 0;
548+
}
549+
532550
return stream_update_dep_on_attach_item(stream);
533551
}
534552

‎deps/nghttp2/lib/nghttp2_stream.h

+21-3
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,15 @@ typedef enum {
9090
NGHTTP2_STREAM_FLAG_DEFERRED_USER = 0x08,
9191
/* bitwise OR of NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL and
9292
NGHTTP2_STREAM_FLAG_DEFERRED_USER. */
93-
NGHTTP2_STREAM_FLAG_DEFERRED_ALL = 0x0c
94-
93+
NGHTTP2_STREAM_FLAG_DEFERRED_ALL = 0x0c,
94+
/* Indicates that this stream is not subject to RFC7540
95+
priorities scheme. */
96+
NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES = 0x10,
97+
/* Ignore client RFC 9218 priority signal. */
98+
NGHTTP2_STREAM_FLAG_IGNORE_CLIENT_PRIORITIES = 0x20,
99+
/* Indicates that RFC 9113 leading and trailing white spaces
100+
validation against a field value is not performed. */
101+
NGHTTP2_STREAM_FLAG_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION = 0x40,
95102
} nghttp2_stream_flag;
96103

97104
/* HTTP related flags to enforce HTTP semantics */
@@ -132,6 +139,11 @@ typedef enum {
132139
/* set if final response is expected */
133140
NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE = 1 << 14,
134141
NGHTTP2_HTTP_FLAG__PROTOCOL = 1 << 15,
142+
/* set if priority header field is received */
143+
NGHTTP2_HTTP_FLAG_PRIORITY = 1 << 16,
144+
/* set if an error is encountered while parsing priority header
145+
field */
146+
NGHTTP2_HTTP_FLAG_BAD_PRIORITY = 1 << 17,
135147
} nghttp2_http_flag;
136148

137149
struct nghttp2_stream {
@@ -204,7 +216,7 @@ struct nghttp2_stream {
204216
/* status code from remote server */
205217
int16_t status_code;
206218
/* Bitwise OR of zero or more nghttp2_http_flag values */
207-
uint16_t http_flags;
219+
uint32_t http_flags;
208220
/* This is bitwise-OR of 0 or more of nghttp2_stream_flag. */
209221
uint8_t flags;
210222
/* Bitwise OR of zero or more nghttp2_shut_flag values */
@@ -218,6 +230,12 @@ struct nghttp2_stream {
218230
this stream. The nonzero does not necessarily mean WINDOW_UPDATE
219231
is not queued. */
220232
uint8_t window_update_queued;
233+
/* extpri is a stream priority produced by nghttp2_extpri_to_uint8
234+
used by RFC 9218 extensible priorities. */
235+
uint8_t extpri;
236+
/* http_extpri is a stream priority received in HTTP request header
237+
fields and produced by nghttp2_extpri_to_uint8. */
238+
uint8_t http_extpri;
221239
};
222240

223241
void nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id,

‎deps/nghttp2/lib/nghttp2_submit.c

+80-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ int32_t nghttp2_submit_headers(nghttp2_session *session, uint8_t flags,
196196

197197
flags &= NGHTTP2_FLAG_END_STREAM;
198198

199-
if (pri_spec && !nghttp2_priority_spec_check_default(pri_spec)) {
199+
if (pri_spec && !nghttp2_priority_spec_check_default(pri_spec) &&
200+
session->remote_settings.no_rfc7540_priorities != 1) {
200201
rv = detect_self_dependency(session, stream_id, pri_spec);
201202
if (rv != 0) {
202203
return rv;
@@ -229,6 +230,10 @@ int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags,
229230

230231
mem = &session->mem;
231232

233+
if (session->remote_settings.no_rfc7540_priorities == 1) {
234+
return 0;
235+
}
236+
232237
if (stream_id == 0 || pri_spec == NULL) {
233238
return NGHTTP2_ERR_INVALID_ARGUMENT;
234239
}
@@ -662,6 +667,78 @@ int nghttp2_submit_origin(nghttp2_session *session, uint8_t flags,
662667
return rv;
663668
}
664669

670+
int nghttp2_submit_priority_update(nghttp2_session *session, uint8_t flags,
671+
int32_t stream_id,
672+
const uint8_t *field_value,
673+
size_t field_value_len) {
674+
nghttp2_mem *mem;
675+
uint8_t *buf, *p;
676+
nghttp2_outbound_item *item;
677+
nghttp2_frame *frame;
678+
nghttp2_ext_priority_update *priority_update;
679+
int rv;
680+
(void)flags;
681+
682+
mem = &session->mem;
683+
684+
if (session->server) {
685+
return NGHTTP2_ERR_INVALID_STATE;
686+
}
687+
688+
if (session->remote_settings.no_rfc7540_priorities == 0) {
689+
return 0;
690+
}
691+
692+
if (stream_id == 0 || 4 + field_value_len > NGHTTP2_MAX_PAYLOADLEN) {
693+
return NGHTTP2_ERR_INVALID_ARGUMENT;
694+
}
695+
696+
if (field_value_len) {
697+
buf = nghttp2_mem_malloc(mem, field_value_len + 1);
698+
if (buf == NULL) {
699+
return NGHTTP2_ERR_NOMEM;
700+
}
701+
702+
p = nghttp2_cpymem(buf, field_value, field_value_len);
703+
*p = '\0';
704+
} else {
705+
buf = NULL;
706+
}
707+
708+
item = nghttp2_mem_malloc(mem, sizeof(nghttp2_outbound_item));
709+
if (item == NULL) {
710+
rv = NGHTTP2_ERR_NOMEM;
711+
goto fail_item_malloc;
712+
}
713+
714+
nghttp2_outbound_item_init(item);
715+
716+
item->aux_data.ext.builtin = 1;
717+
718+
priority_update = &item->ext_frame_payload.priority_update;
719+
720+
frame = &item->frame;
721+
frame->ext.payload = priority_update;
722+
723+
nghttp2_frame_priority_update_init(&frame->ext, stream_id, buf,
724+
field_value_len);
725+
726+
rv = nghttp2_session_add_item(session, item);
727+
if (rv != 0) {
728+
nghttp2_frame_priority_update_free(&frame->ext, mem);
729+
nghttp2_mem_free(mem, item);
730+
731+
return rv;
732+
}
733+
734+
return 0;
735+
736+
fail_item_malloc:
737+
free(buf);
738+
739+
return rv;
740+
}
741+
665742
static uint8_t set_request_flags(const nghttp2_priority_spec *pri_spec,
666743
const nghttp2_data_provider *data_prd) {
667744
uint8_t flags = NGHTTP2_FLAG_NONE;
@@ -688,7 +765,8 @@ int32_t nghttp2_submit_request(nghttp2_session *session,
688765
return NGHTTP2_ERR_PROTO;
689766
}
690767

691-
if (pri_spec && !nghttp2_priority_spec_check_default(pri_spec)) {
768+
if (pri_spec && !nghttp2_priority_spec_check_default(pri_spec) &&
769+
session->remote_settings.no_rfc7540_priorities != 1) {
692770
rv = detect_self_dependency(session, -1, pri_spec);
693771
if (rv != 0) {
694772
return rv;

‎deps/nghttp2/nghttp2.gyp

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
'lib/nghttp2_buf.c',
3939
'lib/nghttp2_callbacks.c',
4040
'lib/nghttp2_debug.c',
41+
'lib/nghttp2_extpri.c',
4142
'lib/nghttp2_frame.c',
4243
'lib/nghttp2_hd.c',
4344
'lib/nghttp2_hd_huffman.c',

0 commit comments

Comments
 (0)
Please sign in to comment.