Skip to content

Commit

Permalink
deps: update nghttp2 to 1.59.0
Browse files Browse the repository at this point in the history
PR-URL: #51581
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
nodejs-github-bot authored and pull[bot] committed Jun 2, 2024
1 parent b8727b8 commit 5d59cf9
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 53 deletions.
2 changes: 1 addition & 1 deletion deps/nghttp2/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set(NGHTTP2_SOURCES
nghttp2_stream.c nghttp2_outbound_item.c
nghttp2_session.c nghttp2_submit.c
nghttp2_helper.c
nghttp2_npn.c
nghttp2_alpn.c
nghttp2_hd.c nghttp2_hd_huffman.c nghttp2_hd_huffman_data.c
nghttp2_version.c
nghttp2_priority_spec.c
Expand Down
4 changes: 2 additions & 2 deletions deps/nghttp2/lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ OBJECTS = nghttp2_pq.c nghttp2_map.c nghttp2_queue.c \
nghttp2_stream.c nghttp2_outbound_item.c \
nghttp2_session.c nghttp2_submit.c \
nghttp2_helper.c \
nghttp2_npn.c \
nghttp2_alpn.c \
nghttp2_hd.c nghttp2_hd_huffman.c nghttp2_hd_huffman_data.c \
nghttp2_version.c \
nghttp2_priority_spec.c \
Expand All @@ -60,7 +60,7 @@ HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \
nghttp2_frame.h \
nghttp2_buf.h \
nghttp2_session.h nghttp2_helper.h nghttp2_stream.h nghttp2_int.h \
nghttp2_npn.h \
nghttp2_alpn.h \
nghttp2_submit.h nghttp2_outbound_item.h \
nghttp2_net.h \
nghttp2_hd.h nghttp2_hd_huffman.h \
Expand Down
22 changes: 11 additions & 11 deletions deps/nghttp2/lib/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ am__objects_1 =
am__objects_2 = nghttp2_pq.lo nghttp2_map.lo nghttp2_queue.lo \
nghttp2_frame.lo nghttp2_buf.lo nghttp2_stream.lo \
nghttp2_outbound_item.lo nghttp2_session.lo nghttp2_submit.lo \
nghttp2_helper.lo nghttp2_npn.lo nghttp2_hd.lo \
nghttp2_helper.lo nghttp2_alpn.lo nghttp2_hd.lo \
nghttp2_hd_huffman.lo nghttp2_hd_huffman_data.lo \
nghttp2_version.lo nghttp2_priority_spec.lo nghttp2_option.lo \
nghttp2_callbacks.lo nghttp2_mem.lo nghttp2_http.lo \
Expand Down Expand Up @@ -183,15 +183,15 @@ am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/nghttp2_buf.Plo \
./$(DEPDIR)/nghttp2_callbacks.Plo \
am__depfiles_remade = ./$(DEPDIR)/nghttp2_alpn.Plo \
./$(DEPDIR)/nghttp2_buf.Plo ./$(DEPDIR)/nghttp2_callbacks.Plo \
./$(DEPDIR)/nghttp2_debug.Plo ./$(DEPDIR)/nghttp2_extpri.Plo \
./$(DEPDIR)/nghttp2_frame.Plo ./$(DEPDIR)/nghttp2_hd.Plo \
./$(DEPDIR)/nghttp2_hd_huffman.Plo \
./$(DEPDIR)/nghttp2_hd_huffman_data.Plo \
./$(DEPDIR)/nghttp2_helper.Plo ./$(DEPDIR)/nghttp2_http.Plo \
./$(DEPDIR)/nghttp2_map.Plo ./$(DEPDIR)/nghttp2_mem.Plo \
./$(DEPDIR)/nghttp2_npn.Plo ./$(DEPDIR)/nghttp2_option.Plo \
./$(DEPDIR)/nghttp2_option.Plo \
./$(DEPDIR)/nghttp2_outbound_item.Plo \
./$(DEPDIR)/nghttp2_pq.Plo \
./$(DEPDIR)/nghttp2_priority_spec.Plo \
Expand Down Expand Up @@ -502,7 +502,7 @@ OBJECTS = nghttp2_pq.c nghttp2_map.c nghttp2_queue.c \
nghttp2_stream.c nghttp2_outbound_item.c \
nghttp2_session.c nghttp2_submit.c \
nghttp2_helper.c \
nghttp2_npn.c \
nghttp2_alpn.c \
nghttp2_hd.c nghttp2_hd_huffman.c nghttp2_hd_huffman_data.c \
nghttp2_version.c \
nghttp2_priority_spec.c \
Expand All @@ -521,7 +521,7 @@ HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \
nghttp2_frame.h \
nghttp2_buf.h \
nghttp2_session.h nghttp2_helper.h nghttp2_stream.h nghttp2_int.h \
nghttp2_npn.h \
nghttp2_alpn.h \
nghttp2_submit.h nghttp2_outbound_item.h \
nghttp2_net.h \
nghttp2_hd.h nghttp2_hd_huffman.h \
Expand Down Expand Up @@ -621,6 +621,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c

@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_alpn.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_buf.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_callbacks.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_debug.Plo@am__quote@ # am--include-marker
Expand All @@ -633,7 +634,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_http.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_map.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_mem.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_npn.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_option.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_outbound_item.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_pq.Plo@am__quote@ # am--include-marker
Expand Down Expand Up @@ -906,7 +906,8 @@ clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
mostlyclean-am

distclean: distclean-recursive
-rm -f ./$(DEPDIR)/nghttp2_buf.Plo
-rm -f ./$(DEPDIR)/nghttp2_alpn.Plo
-rm -f ./$(DEPDIR)/nghttp2_buf.Plo
-rm -f ./$(DEPDIR)/nghttp2_callbacks.Plo
-rm -f ./$(DEPDIR)/nghttp2_debug.Plo
-rm -f ./$(DEPDIR)/nghttp2_extpri.Plo
Expand All @@ -918,7 +919,6 @@ distclean: distclean-recursive
-rm -f ./$(DEPDIR)/nghttp2_http.Plo
-rm -f ./$(DEPDIR)/nghttp2_map.Plo
-rm -f ./$(DEPDIR)/nghttp2_mem.Plo
-rm -f ./$(DEPDIR)/nghttp2_npn.Plo
-rm -f ./$(DEPDIR)/nghttp2_option.Plo
-rm -f ./$(DEPDIR)/nghttp2_outbound_item.Plo
-rm -f ./$(DEPDIR)/nghttp2_pq.Plo
Expand Down Expand Up @@ -977,7 +977,8 @@ install-ps-am:
installcheck-am:

maintainer-clean: maintainer-clean-recursive
-rm -f ./$(DEPDIR)/nghttp2_buf.Plo
-rm -f ./$(DEPDIR)/nghttp2_alpn.Plo
-rm -f ./$(DEPDIR)/nghttp2_buf.Plo
-rm -f ./$(DEPDIR)/nghttp2_callbacks.Plo
-rm -f ./$(DEPDIR)/nghttp2_debug.Plo
-rm -f ./$(DEPDIR)/nghttp2_extpri.Plo
Expand All @@ -989,7 +990,6 @@ maintainer-clean: maintainer-clean-recursive
-rm -f ./$(DEPDIR)/nghttp2_http.Plo
-rm -f ./$(DEPDIR)/nghttp2_map.Plo
-rm -f ./$(DEPDIR)/nghttp2_mem.Plo
-rm -f ./$(DEPDIR)/nghttp2_npn.Plo
-rm -f ./$(DEPDIR)/nghttp2_option.Plo
-rm -f ./$(DEPDIR)/nghttp2_outbound_item.Plo
-rm -f ./$(DEPDIR)/nghttp2_pq.Plo
Expand Down
2 changes: 1 addition & 1 deletion deps/nghttp2/lib/Makefile.msvc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ NGHTTP2_SRC := nghttp2_pq.c \
nghttp2_session.c \
nghttp2_submit.c \
nghttp2_helper.c \
nghttp2_npn.c \
nghttp2_alpn.c \
nghttp2_hd.c \
nghttp2_hd_huffman.c \
nghttp2_hd_huffman_data.c \
Expand Down
137 changes: 123 additions & 14 deletions deps/nghttp2/lib/includes/nghttp2/nghttp2.h
Original file line number Diff line number Diff line change
Expand Up @@ -1997,7 +1997,7 @@ typedef int (*nghttp2_on_extension_chunk_recv_callback)(
* ``NULL``. The |*payload| is available as ``frame->ext.payload`` in
* :type:`nghttp2_on_frame_recv_callback`. Therefore if application
* can free that memory inside :type:`nghttp2_on_frame_recv_callback`
* callback. Of course, application has a liberty not ot use
* callback. Of course, application has a liberty not to use
* |*payload|, and do its own mechanism to process extension frames.
*
* To abort processing this extension frame, return
Expand Down Expand Up @@ -4958,6 +4958,55 @@ NGHTTP2_EXTERN int nghttp2_session_change_extpri_stream_priority(
nghttp2_session *session, int32_t stream_id, const nghttp2_extpri *extpri,
int ignore_client_signal);

/**
* @function
*
* Stores the stream priority of the existing stream denoted by
* |stream_id| in the object pointed by |extpri|. This function is
* meant to be used by server for :rfc:`9218` extensible
* prioritization scheme.
*
* If |session| is initialized as client, this function returns
* :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`.
*
* If
* :enum:`nghttp2_settings_id.NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES`
* of value of 1 is not submitted via `nghttp2_submit_settings()`,
* this function does nothing and returns 0.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_STATE`
* The |session| is initialized as client.
* :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT`
* |stream_id| is zero; or a stream denoted by |stream_id| is not
* found.
*/
NGHTTP2_EXTERN int nghttp2_session_get_extpri_stream_priority(
nghttp2_session *session, nghttp2_extpri *extpri, int32_t stream_id);

/**
* @function
*
* Parses Priority header field value pointed by |value| of length
* |len|, and stores the result in the object pointed by |extpri|.
* Priority header field is defined in :rfc:`9218`.
*
* This function does not initialize the object pointed by |extpri|
* before storing the result. It only assigns the values that the
* parser correctly extracted to fields.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* :enum:`nghttp2_error.NGHTTP2_ERR_INVALID_ARGUMENT`
* Failed to parse the header field value.
*/
NGHTTP2_EXTERN int nghttp2_extpri_parse_priority(nghttp2_extpri *extpri,
const uint8_t *value,
size_t len);

/**
* @function
*
Expand All @@ -4973,11 +5022,14 @@ NGHTTP2_EXTERN int nghttp2_nv_compare_name(const nghttp2_nv *lhs,
/**
* @function
*
* A helper function for dealing with NPN in client side or ALPN in
* server side. The |in| contains peer's protocol list in preferable
* order. The format of |in| is length-prefixed and not
* null-terminated. For example, ``h2`` and
* ``http/1.1`` stored in |in| like this::
* .. warning::
*
* Deprecated. Use `nghttp2_select_alpn` instead.
*
* A helper function for dealing with ALPN in server side. The |in|
* contains peer's protocol list in preferable order. The format of
* |in| is length-prefixed and not null-terminated. For example,
* ``h2`` and ``http/1.1`` stored in |in| like this::
*
* in[0] = 2
* in[1..2] = "h2"
Expand All @@ -5002,20 +5054,18 @@ NGHTTP2_EXTERN int nghttp2_nv_compare_name(const nghttp2_nv *lhs,
*
* For ALPN, refer to https://tools.ietf.org/html/rfc7301
*
* See http://technotes.googlecode.com/git/nextprotoneg.html for more
* details about NPN.
*
* For NPN, to use this method you should do something like::
* To use this method you should do something like::
*
* static int select_next_proto_cb(SSL* ssl,
* unsigned char **out,
* static int alpn_select_proto_cb(SSL* ssl,
* const unsigned char **out,
* unsigned char *outlen,
* const unsigned char *in,
* unsigned int inlen,
* void *arg)
* {
* int rv;
* rv = nghttp2_select_next_protocol(out, outlen, in, inlen);
* rv = nghttp2_select_next_protocol((unsigned char**)out, outlen,
* in, inlen);
* if (rv == -1) {
* return SSL_TLSEXT_ERR_NOACK;
* }
Expand All @@ -5025,14 +5075,73 @@ NGHTTP2_EXTERN int nghttp2_nv_compare_name(const nghttp2_nv *lhs,
* return SSL_TLSEXT_ERR_OK;
* }
* ...
* SSL_CTX_set_next_proto_select_cb(ssl_ctx, select_next_proto_cb, my_obj);
* SSL_CTX_set_alpn_select_cb(ssl_ctx, alpn_select_proto_cb, my_obj);
*
*/
NGHTTP2_EXTERN int nghttp2_select_next_protocol(unsigned char **out,
unsigned char *outlen,
const unsigned char *in,
unsigned int inlen);

/**
* @function
*
* A helper function for dealing with ALPN in server side. The |in|
* contains peer's protocol list in preferable order. The format of
* |in| is length-prefixed and not null-terminated. For example,
* ``h2`` and ``http/1.1`` stored in |in| like this::
*
* in[0] = 2
* in[1..2] = "h2"
* in[3] = 8
* in[4..11] = "http/1.1"
* inlen = 12
*
* The selection algorithm is as follows:
*
* 1. If peer's list contains HTTP/2 protocol the library supports,
* it is selected and returns 1. The following step is not taken.
*
* 2. If peer's list contains ``http/1.1``, this function selects
* ``http/1.1`` and returns 0. The following step is not taken.
*
* 3. This function selects nothing and returns -1 (So called
* non-overlap case). In this case, |out| and |outlen| are left
* untouched.
*
* Selecting ``h2`` means that ``h2`` is written into |*out| and its
* length (which is 2) is assigned to |*outlen|.
*
* For ALPN, refer to https://tools.ietf.org/html/rfc7301
*
* To use this method you should do something like::
*
* static int alpn_select_proto_cb(SSL* ssl,
* const unsigned char **out,
* unsigned char *outlen,
* const unsigned char *in,
* unsigned int inlen,
* void *arg)
* {
* int rv;
* rv = nghttp2_select_alpn(out, outlen, in, inlen);
* if (rv == -1) {
* return SSL_TLSEXT_ERR_NOACK;
* }
* if (rv == 1) {
* ((MyType*)arg)->http2_selected = 1;
* }
* return SSL_TLSEXT_ERR_OK;
* }
* ...
* SSL_CTX_set_alpn_select_cb(ssl_ctx, alpn_select_proto_cb, my_obj);
*
*/
NGHTTP2_EXTERN int nghttp2_select_alpn(const unsigned char **out,
unsigned char *outlen,
const unsigned char *in,
unsigned int inlen);

/**
* @function
*
Expand Down
4 changes: 2 additions & 2 deletions deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
* @macro
* Version number of the nghttp2 library release
*/
#define NGHTTP2_VERSION "1.58.0"
#define NGHTTP2_VERSION "1.59.0"

/**
* @macro
* Numerical representation of the version number of the nghttp2 library
* release. This is a 24 bit number with 8 bits for major number, 8 bits
* for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203.
*/
#define NGHTTP2_VERSION_NUM 0x013a00
#define NGHTTP2_VERSION_NUM 0x013b00

#endif /* NGHTTP2VER_H */
29 changes: 21 additions & 8 deletions deps/nghttp2/lib/nghttp2_npn.c → deps/nghttp2/lib/nghttp2_alpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "nghttp2_npn.h"
#include "nghttp2_alpn.h"

#include <string.h>

static int select_next_protocol(unsigned char **out, unsigned char *outlen,
const unsigned char *in, unsigned int inlen,
const char *key, unsigned int keylen) {
static int select_alpn(const unsigned char **out, unsigned char *outlen,
const unsigned char *in, unsigned int inlen,
const char *key, unsigned int keylen) {
unsigned int i;
for (i = 0; i + keylen <= inlen; i += (unsigned int)(in[i] + 1)) {
if (memcmp(&in[i], key, keylen) == 0) {
Expand All @@ -45,12 +45,25 @@ static int select_next_protocol(unsigned char **out, unsigned char *outlen,

int nghttp2_select_next_protocol(unsigned char **out, unsigned char *outlen,
const unsigned char *in, unsigned int inlen) {
if (select_next_protocol(out, outlen, in, inlen, NGHTTP2_PROTO_ALPN,
NGHTTP2_PROTO_ALPN_LEN) == 0) {
if (select_alpn((const unsigned char **)out, outlen, in, inlen,
NGHTTP2_PROTO_ALPN, NGHTTP2_PROTO_ALPN_LEN) == 0) {
return 1;
}
if (select_next_protocol(out, outlen, in, inlen, NGHTTP2_HTTP_1_1_ALPN,
NGHTTP2_HTTP_1_1_ALPN_LEN) == 0) {
if (select_alpn((const unsigned char **)out, outlen, in, inlen,
NGHTTP2_HTTP_1_1_ALPN, NGHTTP2_HTTP_1_1_ALPN_LEN) == 0) {
return 0;
}
return -1;
}

int nghttp2_select_alpn(const unsigned char **out, unsigned char *outlen,
const unsigned char *in, unsigned int inlen) {
if (select_alpn(out, outlen, in, inlen, NGHTTP2_PROTO_ALPN,
NGHTTP2_PROTO_ALPN_LEN) == 0) {
return 1;
}
if (select_alpn(out, outlen, in, inlen, NGHTTP2_HTTP_1_1_ALPN,
NGHTTP2_HTTP_1_1_ALPN_LEN) == 0) {
return 0;
}
return -1;
Expand Down
Loading

0 comments on commit 5d59cf9

Please sign in to comment.