@@ -634,7 +634,11 @@ typedef enum {
634
634
* The ORIGIN frame, which is defined by `RFC 8336
635
635
* <https://tools.ietf.org/html/rfc8336>`_.
636
636
*/
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
638
642
} nghttp2_frame_type ;
639
643
640
644
/**
@@ -703,7 +707,11 @@ typedef enum {
703
707
* SETTINGS_ENABLE_CONNECT_PROTOCOL
704
708
* (`RFC 8441 <https://tools.ietf.org/html/rfc8441>`_)
705
709
*/
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
707
715
} nghttp2_settings_id ;
708
716
/* Note: If we add SETTINGS, update the capacity of
709
717
NGHTTP2_INBOUND_NUM_IV as well */
@@ -1422,12 +1430,6 @@ typedef ssize_t (*nghttp2_recv_callback)(nghttp2_session *session, uint8_t *buf,
1422
1430
* respectively. The header name/value pairs are emitted via
1423
1431
* :type:`nghttp2_on_header_callback`.
1424
1432
*
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
- *
1431
1433
* Only HEADERS and DATA frame can signal the end of incoming data.
1432
1434
* If ``frame->hd.flags & NGHTTP2_FLAG_END_STREAM`` is nonzero, the
1433
1435
* |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,
2693
2695
* This option prevents the library from retaining closed streams to
2694
2696
* maintain the priority tree. If this option is set to nonzero,
2695
2697
* 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.
2696
2703
*/
2697
2704
NGHTTP2_EXTERN void nghttp2_option_set_no_closed_streams (nghttp2_option * option ,
2698
2705
int val );
@@ -2719,6 +2726,36 @@ NGHTTP2_EXTERN void nghttp2_option_set_max_outbound_ack(nghttp2_option *option,
2719
2726
NGHTTP2_EXTERN void nghttp2_option_set_max_settings (nghttp2_option * option ,
2720
2727
size_t val );
2721
2728
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
+
2722
2759
/**
2723
2760
* @function
2724
2761
*
@@ -3589,6 +3626,11 @@ NGHTTP2_EXTERN int nghttp2_session_consume_stream(nghttp2_session *session,
3589
3626
* found, we use default priority instead of given |pri_spec|. That
3590
3627
* is make stream depend on root stream with weight 16.
3591
3628
*
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
+ *
3592
3634
* This function returns 0 if it succeeds, or one of the following
3593
3635
* negative error codes:
3594
3636
*
@@ -3632,6 +3674,11 @@ nghttp2_session_change_stream_priority(nghttp2_session *session,
3632
3674
* found, we use default priority instead of given |pri_spec|. That
3633
3675
* is make stream depend on root stream with weight 16.
3634
3676
*
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
+ *
3635
3682
* This function returns 0 if it succeeds, or one of the following
3636
3683
* negative error codes:
3637
3684
*
@@ -3837,6 +3884,11 @@ nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec);
3837
3884
* :macro:`NGHTTP2_MAX_WEIGHT`, it becomes
3838
3885
* :macro:`NGHTTP2_MAX_WEIGHT`.
3839
3886
*
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
+ *
3840
3892
* The |nva| is an array of name/value pair :type:`nghttp2_nv` with
3841
3893
* |nvlen| elements. The application is responsible to include
3842
3894
* required pseudo-header fields (header field whose name starts with
@@ -4057,6 +4109,11 @@ NGHTTP2_EXTERN int nghttp2_submit_trailer(nghttp2_session *session,
4057
4109
* :macro:`NGHTTP2_MIN_WEIGHT`. If it is strictly greater than
4058
4110
* :macro:`NGHTTP2_MAX_WEIGHT`, it becomes :macro:`NGHTTP2_MAX_WEIGHT`.
4059
4111
*
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
+ *
4060
4117
* The |nva| is an array of name/value pair :type:`nghttp2_nv` with
4061
4118
* |nvlen| elements. The application is responsible to include
4062
4119
* 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,
4184
4241
* :macro:`NGHTTP2_MAX_WEIGHT`, it becomes
4185
4242
* :macro:`NGHTTP2_MAX_WEIGHT`.
4186
4243
*
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
+ *
4187
4249
* This function returns 0 if it succeeds, or one of the following
4188
4250
* negative error codes:
4189
4251
*
@@ -4198,6 +4260,61 @@ nghttp2_submit_priority(nghttp2_session *session, uint8_t flags,
4198
4260
int32_t stream_id ,
4199
4261
const nghttp2_priority_spec * pri_spec );
4200
4262
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
+
4201
4318
/**
4202
4319
* @function
4203
4320
*
@@ -4722,6 +4839,108 @@ NGHTTP2_EXTERN int nghttp2_submit_origin(nghttp2_session *session,
4722
4839
const nghttp2_origin_entry * ov ,
4723
4840
size_t nov );
4724
4841
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
+
4725
4944
/**
4726
4945
* @function
4727
4946
*
@@ -4833,9 +5052,23 @@ NGHTTP2_EXTERN int nghttp2_check_header_name(const uint8_t *name, size_t len);
4833
5052
* Returns nonzero if HTTP header field value |value| of length |len|
4834
5053
* is valid according to
4835
5054
* 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.
4836
5058
*/
4837
5059
NGHTTP2_EXTERN int nghttp2_check_header_value (const uint8_t * value , size_t len );
4838
5060
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
+
4839
5072
/**
4840
5073
* @function
4841
5074
*
0 commit comments