@@ -1997,7 +1997,7 @@ typedef int (*nghttp2_on_extension_chunk_recv_callback)(
19971997 * ``NULL``. The |*payload| is available as ``frame->ext.payload`` in
19981998 * :type:`nghttp2_on_frame_recv_callback`. Therefore if application
19991999 * 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
20012001 * |*payload|, and do its own mechanism to process extension frames.
20022002 *
20032003 * To abort processing this extension frame, return
@@ -4958,6 +4958,55 @@ NGHTTP2_EXTERN int nghttp2_session_change_extpri_stream_priority(
49584958 nghttp2_session * session , int32_t stream_id , const nghttp2_extpri * extpri ,
49594959 int ignore_client_signal );
49604960
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+
49615010/**
49625011 * @function
49635012 *
@@ -4973,11 +5022,14 @@ NGHTTP2_EXTERN int nghttp2_nv_compare_name(const nghttp2_nv *lhs,
49735022/**
49745023 * @function
49755024 *
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::
49815033 *
49825034 * in[0] = 2
49835035 * in[1..2] = "h2"
@@ -5002,20 +5054,18 @@ NGHTTP2_EXTERN int nghttp2_nv_compare_name(const nghttp2_nv *lhs,
50025054 *
50035055 * For ALPN, refer to https://tools.ietf.org/html/rfc7301
50045056 *
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::
50095058 *
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,
50125061 * unsigned char *outlen,
50135062 * const unsigned char *in,
50145063 * unsigned int inlen,
50155064 * void *arg)
50165065 * {
50175066 * 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);
50195069 * if (rv == -1) {
50205070 * return SSL_TLSEXT_ERR_NOACK;
50215071 * }
@@ -5025,14 +5075,73 @@ NGHTTP2_EXTERN int nghttp2_nv_compare_name(const nghttp2_nv *lhs,
50255075 * return SSL_TLSEXT_ERR_OK;
50265076 * }
50275077 * ...
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);
50295079 *
50305080 */
50315081NGHTTP2_EXTERN int nghttp2_select_next_protocol (unsigned char * * out ,
50325082 unsigned char * outlen ,
50335083 const unsigned char * in ,
50345084 unsigned int inlen );
50355085
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+
50365145/**
50375146 * @function
50385147 *
0 commit comments