Skip to content

Commit 68885d5

Browse files
deps: update nghttp2 to 1.59.0
PR-URL: #51581 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent d1114c4 commit 68885d5

12 files changed

+209
-53
lines changed

deps/nghttp2/lib/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(NGHTTP2_SOURCES
1414
nghttp2_stream.c nghttp2_outbound_item.c
1515
nghttp2_session.c nghttp2_submit.c
1616
nghttp2_helper.c
17-
nghttp2_npn.c
17+
nghttp2_alpn.c
1818
nghttp2_hd.c nghttp2_hd_huffman.c nghttp2_hd_huffman_data.c
1919
nghttp2_version.c
2020
nghttp2_priority_spec.c

deps/nghttp2/lib/Makefile.am

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ OBJECTS = nghttp2_pq.c nghttp2_map.c nghttp2_queue.c \
4141
nghttp2_stream.c nghttp2_outbound_item.c \
4242
nghttp2_session.c nghttp2_submit.c \
4343
nghttp2_helper.c \
44-
nghttp2_npn.c \
44+
nghttp2_alpn.c \
4545
nghttp2_hd.c nghttp2_hd_huffman.c nghttp2_hd_huffman_data.c \
4646
nghttp2_version.c \
4747
nghttp2_priority_spec.c \
@@ -60,7 +60,7 @@ HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \
6060
nghttp2_frame.h \
6161
nghttp2_buf.h \
6262
nghttp2_session.h nghttp2_helper.h nghttp2_stream.h nghttp2_int.h \
63-
nghttp2_npn.h \
63+
nghttp2_alpn.h \
6464
nghttp2_submit.h nghttp2_outbound_item.h \
6565
nghttp2_net.h \
6666
nghttp2_hd.h nghttp2_hd_huffman.h \

deps/nghttp2/lib/Makefile.in

+11-11
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ am__objects_1 =
153153
am__objects_2 = nghttp2_pq.lo nghttp2_map.lo nghttp2_queue.lo \
154154
nghttp2_frame.lo nghttp2_buf.lo nghttp2_stream.lo \
155155
nghttp2_outbound_item.lo nghttp2_session.lo nghttp2_submit.lo \
156-
nghttp2_helper.lo nghttp2_npn.lo nghttp2_hd.lo \
156+
nghttp2_helper.lo nghttp2_alpn.lo nghttp2_hd.lo \
157157
nghttp2_hd_huffman.lo nghttp2_hd_huffman_data.lo \
158158
nghttp2_version.lo nghttp2_priority_spec.lo nghttp2_option.lo \
159159
nghttp2_callbacks.lo nghttp2_mem.lo nghttp2_http.lo \
@@ -183,15 +183,15 @@ am__v_at_1 =
183183
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
184184
depcomp = $(SHELL) $(top_srcdir)/depcomp
185185
am__maybe_remake_depfiles = depfiles
186-
am__depfiles_remade = ./$(DEPDIR)/nghttp2_buf.Plo \
187-
./$(DEPDIR)/nghttp2_callbacks.Plo \
186+
am__depfiles_remade = ./$(DEPDIR)/nghttp2_alpn.Plo \
187+
./$(DEPDIR)/nghttp2_buf.Plo ./$(DEPDIR)/nghttp2_callbacks.Plo \
188188
./$(DEPDIR)/nghttp2_debug.Plo ./$(DEPDIR)/nghttp2_extpri.Plo \
189189
./$(DEPDIR)/nghttp2_frame.Plo ./$(DEPDIR)/nghttp2_hd.Plo \
190190
./$(DEPDIR)/nghttp2_hd_huffman.Plo \
191191
./$(DEPDIR)/nghttp2_hd_huffman_data.Plo \
192192
./$(DEPDIR)/nghttp2_helper.Plo ./$(DEPDIR)/nghttp2_http.Plo \
193193
./$(DEPDIR)/nghttp2_map.Plo ./$(DEPDIR)/nghttp2_mem.Plo \
194-
./$(DEPDIR)/nghttp2_npn.Plo ./$(DEPDIR)/nghttp2_option.Plo \
194+
./$(DEPDIR)/nghttp2_option.Plo \
195195
./$(DEPDIR)/nghttp2_outbound_item.Plo \
196196
./$(DEPDIR)/nghttp2_pq.Plo \
197197
./$(DEPDIR)/nghttp2_priority_spec.Plo \
@@ -502,7 +502,7 @@ OBJECTS = nghttp2_pq.c nghttp2_map.c nghttp2_queue.c \
502502
nghttp2_stream.c nghttp2_outbound_item.c \
503503
nghttp2_session.c nghttp2_submit.c \
504504
nghttp2_helper.c \
505-
nghttp2_npn.c \
505+
nghttp2_alpn.c \
506506
nghttp2_hd.c nghttp2_hd_huffman.c nghttp2_hd_huffman_data.c \
507507
nghttp2_version.c \
508508
nghttp2_priority_spec.c \
@@ -521,7 +521,7 @@ HFILES = nghttp2_pq.h nghttp2_int.h nghttp2_map.h nghttp2_queue.h \
521521
nghttp2_frame.h \
522522
nghttp2_buf.h \
523523
nghttp2_session.h nghttp2_helper.h nghttp2_stream.h nghttp2_int.h \
524-
nghttp2_npn.h \
524+
nghttp2_alpn.h \
525525
nghttp2_submit.h nghttp2_outbound_item.h \
526526
nghttp2_net.h \
527527
nghttp2_hd.h nghttp2_hd_huffman.h \
@@ -621,6 +621,7 @@ mostlyclean-compile:
621621
distclean-compile:
622622
-rm -f *.tab.c
623623

624+
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_alpn.Plo@am__quote@ # am--include-marker
624625
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_buf.Plo@am__quote@ # am--include-marker
625626
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_callbacks.Plo@am__quote@ # am--include-marker
626627
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_debug.Plo@am__quote@ # am--include-marker
@@ -633,7 +634,6 @@ distclean-compile:
633634
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_http.Plo@am__quote@ # am--include-marker
634635
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_map.Plo@am__quote@ # am--include-marker
635636
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_mem.Plo@am__quote@ # am--include-marker
636-
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_npn.Plo@am__quote@ # am--include-marker
637637
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_option.Plo@am__quote@ # am--include-marker
638638
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_outbound_item.Plo@am__quote@ # am--include-marker
639639
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nghttp2_pq.Plo@am__quote@ # am--include-marker
@@ -906,7 +906,8 @@ clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
906906
mostlyclean-am
907907

908908
distclean: distclean-recursive
909-
-rm -f ./$(DEPDIR)/nghttp2_buf.Plo
909+
-rm -f ./$(DEPDIR)/nghttp2_alpn.Plo
910+
-rm -f ./$(DEPDIR)/nghttp2_buf.Plo
910911
-rm -f ./$(DEPDIR)/nghttp2_callbacks.Plo
911912
-rm -f ./$(DEPDIR)/nghttp2_debug.Plo
912913
-rm -f ./$(DEPDIR)/nghttp2_extpri.Plo
@@ -918,7 +919,6 @@ distclean: distclean-recursive
918919
-rm -f ./$(DEPDIR)/nghttp2_http.Plo
919920
-rm -f ./$(DEPDIR)/nghttp2_map.Plo
920921
-rm -f ./$(DEPDIR)/nghttp2_mem.Plo
921-
-rm -f ./$(DEPDIR)/nghttp2_npn.Plo
922922
-rm -f ./$(DEPDIR)/nghttp2_option.Plo
923923
-rm -f ./$(DEPDIR)/nghttp2_outbound_item.Plo
924924
-rm -f ./$(DEPDIR)/nghttp2_pq.Plo
@@ -977,7 +977,8 @@ install-ps-am:
977977
installcheck-am:
978978

979979
maintainer-clean: maintainer-clean-recursive
980-
-rm -f ./$(DEPDIR)/nghttp2_buf.Plo
980+
-rm -f ./$(DEPDIR)/nghttp2_alpn.Plo
981+
-rm -f ./$(DEPDIR)/nghttp2_buf.Plo
981982
-rm -f ./$(DEPDIR)/nghttp2_callbacks.Plo
982983
-rm -f ./$(DEPDIR)/nghttp2_debug.Plo
983984
-rm -f ./$(DEPDIR)/nghttp2_extpri.Plo
@@ -989,7 +990,6 @@ maintainer-clean: maintainer-clean-recursive
989990
-rm -f ./$(DEPDIR)/nghttp2_http.Plo
990991
-rm -f ./$(DEPDIR)/nghttp2_map.Plo
991992
-rm -f ./$(DEPDIR)/nghttp2_mem.Plo
992-
-rm -f ./$(DEPDIR)/nghttp2_npn.Plo
993993
-rm -f ./$(DEPDIR)/nghttp2_option.Plo
994994
-rm -f ./$(DEPDIR)/nghttp2_outbound_item.Plo
995995
-rm -f ./$(DEPDIR)/nghttp2_pq.Plo

deps/nghttp2/lib/Makefile.msvc

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ NGHTTP2_SRC := nghttp2_pq.c \
7474
nghttp2_session.c \
7575
nghttp2_submit.c \
7676
nghttp2_helper.c \
77-
nghttp2_npn.c \
77+
nghttp2_alpn.c \
7878
nghttp2_hd.c \
7979
nghttp2_hd_huffman.c \
8080
nghttp2_hd_huffman_data.c \

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

+123-14
Original file line numberDiff line numberDiff line change
@@ -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
*/
50315081
NGHTTP2_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
*

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.58.0"
32+
#define NGHTTP2_VERSION "1.59.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 0x013a00
40+
#define NGHTTP2_VERSION_NUM 0x013b00
4141

4242
#endif /* NGHTTP2VER_H */

deps/nghttp2/lib/nghttp2_npn.c deps/nghttp2/lib/nghttp2_alpn.c

+21-8
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2323
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2424
*/
25-
#include "nghttp2_npn.h"
25+
#include "nghttp2_alpn.h"
2626

2727
#include <string.h>
2828

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

4646
int nghttp2_select_next_protocol(unsigned char **out, unsigned char *outlen,
4747
const unsigned char *in, unsigned int inlen) {
48-
if (select_next_protocol(out, outlen, in, inlen, NGHTTP2_PROTO_ALPN,
49-
NGHTTP2_PROTO_ALPN_LEN) == 0) {
48+
if (select_alpn((const unsigned char **)out, outlen, in, inlen,
49+
NGHTTP2_PROTO_ALPN, NGHTTP2_PROTO_ALPN_LEN) == 0) {
5050
return 1;
5151
}
52-
if (select_next_protocol(out, outlen, in, inlen, NGHTTP2_HTTP_1_1_ALPN,
53-
NGHTTP2_HTTP_1_1_ALPN_LEN) == 0) {
52+
if (select_alpn((const unsigned char **)out, outlen, in, inlen,
53+
NGHTTP2_HTTP_1_1_ALPN, NGHTTP2_HTTP_1_1_ALPN_LEN) == 0) {
54+
return 0;
55+
}
56+
return -1;
57+
}
58+
59+
int nghttp2_select_alpn(const unsigned char **out, unsigned char *outlen,
60+
const unsigned char *in, unsigned int inlen) {
61+
if (select_alpn(out, outlen, in, inlen, NGHTTP2_PROTO_ALPN,
62+
NGHTTP2_PROTO_ALPN_LEN) == 0) {
63+
return 1;
64+
}
65+
if (select_alpn(out, outlen, in, inlen, NGHTTP2_HTTP_1_1_ALPN,
66+
NGHTTP2_HTTP_1_1_ALPN_LEN) == 0) {
5467
return 0;
5568
}
5669
return -1;

0 commit comments

Comments
 (0)