@@ -1997,7 +1997,7 @@ typedef int (*nghttp2_on_extension_chunk_recv_callback)(
1997
1997
* ``NULL``. The |*payload| is available as ``frame->ext.payload`` in
1998
1998
* :type:`nghttp2_on_frame_recv_callback`. Therefore if application
1999
1999
* can free that memory inside :type:`nghttp2_on_frame_recv_callback`
2000
- * callback. Of course, application has a liberty not ot use
2000
+ * callback. Of course, application has a liberty not to use
2001
2001
* |*payload|, and do its own mechanism to process extension frames.
2002
2002
*
2003
2003
* To abort processing this extension frame, return
@@ -4958,6 +4958,55 @@ NGHTTP2_EXTERN int nghttp2_session_change_extpri_stream_priority(
4958
4958
nghttp2_session * session , int32_t stream_id , const nghttp2_extpri * extpri ,
4959
4959
int ignore_client_signal );
4960
4960
4961
+ /**
4962
+ * @function
4963
+ *
4964
+ * Stores the stream priority of the existing stream denoted by
4965
+ * |stream_id| in the object pointed by |extpri|. This function is
4966
+ * meant to be used by server for :rfc:`9218` extensible
4967
+ * prioritization scheme.
4968
+ *
4969
+ * If |session| is initialized as client, this function returns
4970
+ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`.
4971
+ *
4972
+ * If
4973
+ * :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES`
4974
+ * of value of 1 is not submitted via `nghttp2_submit_settings()`,
4975
+ * this function does nothing and returns 0.
4976
+ *
4977
+ * This function returns 0 if it succeeds, or one of the following
4978
+ * negative error codes:
4979
+ *
4980
+ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`
4981
+ * The |session| is initialized as client.
4982
+ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT`
4983
+ * |stream_id| is zero; or a stream denoted by |stream_id| is not
4984
+ * found.
4985
+ */
4986
+ NGHTTP2_EXTERN int nghttp2_session_get_extpri_stream_priority (
4987
+ nghttp2_session * session , nghttp2_extpri * extpri , int32_t stream_id );
4988
+
4989
+ /**
4990
+ * @function
4991
+ *
4992
+ * Parses Priority header field value pointed by |value| of length
4993
+ * |len|, and stores the result in the object pointed by |extpri|.
4994
+ * Priority header field is defined in :rfc:`9218`.
4995
+ *
4996
+ * This function does not initialize the object pointed by |extpri|
4997
+ * before storing the result. It only assigns the values that the
4998
+ * parser correctly extracted to fields.
4999
+ *
5000
+ * This function returns 0 if it succeeds, or one of the following
5001
+ * negative error codes:
5002
+ *
5003
+ * :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT`
5004
+ * Failed to parse the header field value.
5005
+ */
5006
+ NGHTTP2_EXTERN int nghttp2_extpri_parse_priority (nghttp2_extpri * extpri ,
5007
+ const uint8_t * value ,
5008
+ size_t len );
5009
+
4961
5010
/**
4962
5011
* @function
4963
5012
*
@@ -4973,11 +5022,14 @@ NGHTTP2_EXTERN int nghttp2_nv_compare_name(const nghttp2_nv *lhs,
4973
5022
/**
4974
5023
* @function
4975
5024
*
4976
- * A helper function for dealing with NPN in client side or ALPN in
4977
- * server side. The |in| contains peer's protocol list in preferable
4978
- * order. The format of |in| is length-prefixed and not
4979
- * null-terminated. For example, ``h2`` and
4980
- * ``http/1.1`` stored in |in| like this::
5025
+ * .. warning::
5026
+ *
5027
+ * Deprecated. Use `nghttp2_select_alpn` instead.
5028
+ *
5029
+ * A helper function for dealing with ALPN in server side. The |in|
5030
+ * contains peer's protocol list in preferable order. The format of
5031
+ * |in| is length-prefixed and not null-terminated. For example,
5032
+ * ``h2`` and ``http/1.1`` stored in |in| like this::
4981
5033
*
4982
5034
* in[0] = 2
4983
5035
* in[1..2] = "h2"
@@ -5002,20 +5054,18 @@ NGHTTP2_EXTERN int nghttp2_nv_compare_name(const nghttp2_nv *lhs,
5002
5054
*
5003
5055
* For ALPN, refer to https://tools.ietf.org/html/rfc7301
5004
5056
*
5005
- * See http://technotes.googlecode.com/git/nextprotoneg.html for more
5006
- * details about NPN.
5007
- *
5008
- * For NPN, to use this method you should do something like::
5057
+ * To use this method you should do something like::
5009
5058
*
5010
- * static int select_next_proto_cb (SSL* ssl,
5011
- * unsigned char **out,
5059
+ * static int alpn_select_proto_cb (SSL* ssl,
5060
+ * const unsigned char **out,
5012
5061
* unsigned char *outlen,
5013
5062
* const unsigned char *in,
5014
5063
* unsigned int inlen,
5015
5064
* void *arg)
5016
5065
* {
5017
5066
* int rv;
5018
- * rv = nghttp2_select_next_protocol(out, outlen, in, inlen);
5067
+ * rv = nghttp2_select_next_protocol((unsigned char**)out, outlen,
5068
+ * in, inlen);
5019
5069
* if (rv == -1) {
5020
5070
* return SSL_TLSEXT_ERR_NOACK;
5021
5071
* }
@@ -5025,14 +5075,73 @@ NGHTTP2_EXTERN int nghttp2_nv_compare_name(const nghttp2_nv *lhs,
5025
5075
* return SSL_TLSEXT_ERR_OK;
5026
5076
* }
5027
5077
* ...
5028
- * SSL_CTX_set_next_proto_select_cb (ssl_ctx, select_next_proto_cb , my_obj);
5078
+ * SSL_CTX_set_alpn_select_cb (ssl_ctx, alpn_select_proto_cb , my_obj);
5029
5079
*
5030
5080
*/
5031
5081
NGHTTP2_EXTERN int nghttp2_select_next_protocol (unsigned char * * out ,
5032
5082
unsigned char * outlen ,
5033
5083
const unsigned char * in ,
5034
5084
unsigned int inlen );
5035
5085
5086
+ /**
5087
+ * @function
5088
+ *
5089
+ * A helper function for dealing with ALPN in server side. The |in|
5090
+ * contains peer's protocol list in preferable order. The format of
5091
+ * |in| is length-prefixed and not null-terminated. For example,
5092
+ * ``h2`` and ``http/1.1`` stored in |in| like this::
5093
+ *
5094
+ * in[0] = 2
5095
+ * in[1..2] = "h2"
5096
+ * in[3] = 8
5097
+ * in[4..11] = "http/1.1"
5098
+ * inlen = 12
5099
+ *
5100
+ * The selection algorithm is as follows:
5101
+ *
5102
+ * 1. If peer's list contains HTTP/2 protocol the library supports,
5103
+ * it is selected and returns 1. The following step is not taken.
5104
+ *
5105
+ * 2. If peer's list contains ``http/1.1``, this function selects
5106
+ * ``http/1.1`` and returns 0. The following step is not taken.
5107
+ *
5108
+ * 3. This function selects nothing and returns -1 (So called
5109
+ * non-overlap case). In this case, |out| and |outlen| are left
5110
+ * untouched.
5111
+ *
5112
+ * Selecting ``h2`` means that ``h2`` is written into |*out| and its
5113
+ * length (which is 2) is assigned to |*outlen|.
5114
+ *
5115
+ * For ALPN, refer to https://tools.ietf.org/html/rfc7301
5116
+ *
5117
+ * To use this method you should do something like::
5118
+ *
5119
+ * static int alpn_select_proto_cb(SSL* ssl,
5120
+ * const unsigned char **out,
5121
+ * unsigned char *outlen,
5122
+ * const unsigned char *in,
5123
+ * unsigned int inlen,
5124
+ * void *arg)
5125
+ * {
5126
+ * int rv;
5127
+ * rv = nghttp2_select_alpn(out, outlen, in, inlen);
5128
+ * if (rv == -1) {
5129
+ * return SSL_TLSEXT_ERR_NOACK;
5130
+ * }
5131
+ * if (rv == 1) {
5132
+ * ((MyType*)arg)->http2_selected = 1;
5133
+ * }
5134
+ * return SSL_TLSEXT_ERR_OK;
5135
+ * }
5136
+ * ...
5137
+ * SSL_CTX_set_alpn_select_cb(ssl_ctx, alpn_select_proto_cb, my_obj);
5138
+ *
5139
+ */
5140
+ NGHTTP2_EXTERN int nghttp2_select_alpn (const unsigned char * * out ,
5141
+ unsigned char * outlen ,
5142
+ const unsigned char * in ,
5143
+ unsigned int inlen );
5144
+
5036
5145
/**
5037
5146
* @function
5038
5147
*
0 commit comments