1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-23 16:48:49 -05:00

http2: now require nghttp2 >= 1.12.0

To simplify our code and since earlier versions lack important function
calls libcurl needs to function correctly.

nghttp2 1.12.0 was relased on June 26, 2016.

Closes #4961
This commit is contained in:
Daniel Stenberg 2020-02-21 11:30:05 +01:00
parent 3a34b930aa
commit 5808a0d0f5
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
3 changed files with 10 additions and 52 deletions

View File

@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___ # | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____| # \___|\___/|_| \_\_____|
# #
# Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. # Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
# #
# This software is licensed as described in the file COPYING, which # This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms # you should have received as part of this distribution. The terms
@ -3379,9 +3379,9 @@ if test X"$want_h2" != Xno; then
CPPFLAGS="$CPPFLAGS $CPP_H2" CPPFLAGS="$CPPFLAGS $CPP_H2"
LIBS="$LIB_H2 $LIBS" LIBS="$LIB_H2 $LIBS"
# use nghttp2_option_set_no_recv_client_magic to require nghttp2 # use nghttp2_session_set_local_window_size to require nghttp2
# >= 1.0.0 # >= 1.12.0
AC_CHECK_LIB(nghttp2, nghttp2_option_set_no_recv_client_magic, AC_CHECK_LIB(nghttp2, nghttp2_session_set_local_window_size,
[ [
AC_CHECK_HEADERS(nghttp2/nghttp2.h, AC_CHECK_HEADERS(nghttp2/nghttp2.h,
curl_h2_msg="enabled (nghttp2)" curl_h2_msg="enabled (nghttp2)"

View File

@ -97,7 +97,7 @@ Dependencies
- NSS 3.14.x - NSS 3.14.x
- PolarSSL 1.3.0 - PolarSSL 1.3.0
- Heimdal ? - Heimdal ?
- nghttp2 1.0.0 - nghttp2 1.12.0
Operating Systems Operating Systems
----------------- -----------------

View File

@ -43,19 +43,11 @@
#define H2_BUFSIZE 32768 #define H2_BUFSIZE 32768
#if (NGHTTP2_VERSION_NUM < 0x010000) #if (NGHTTP2_VERSION_NUM < 0x010c00)
#error too old nghttp2 version, upgrade! #error too old nghttp2 version, upgrade!
#endif #endif
#if (NGHTTP2_VERSION_NUM > 0x010800) #ifdef CURL_DISABLE_VERBOSE_STRINGS
#define NGHTTP2_HAS_HTTP2_STRERROR 1
#endif
#if (NGHTTP2_VERSION_NUM >= 0x010900)
/* nghttp2_session_callbacks_set_error_callback is present in nghttp2 1.9.0 or
later */
#define NGHTTP2_HAS_ERROR_CALLBACK 1
#else
#define nghttp2_session_callbacks_set_error_callback(x,y) #define nghttp2_session_callbacks_set_error_callback(x,y)
#endif #endif
@ -344,35 +336,6 @@ int Curl_http2_ver(char *p, size_t len)
return msnprintf(p, len, " nghttp2/%s", h2->version_str); return msnprintf(p, len, " nghttp2/%s", h2->version_str);
} }
/* HTTP/2 error code to name based on the Error Code Registry.
https://tools.ietf.org/html/rfc7540#page-77
nghttp2_error_code enums are identical.
*/
static const char *http2_strerror(uint32_t err)
{
#ifndef NGHTTP2_HAS_HTTP2_STRERROR
const char *str[] = {
"NO_ERROR", /* 0x0 */
"PROTOCOL_ERROR", /* 0x1 */
"INTERNAL_ERROR", /* 0x2 */
"FLOW_CONTROL_ERROR", /* 0x3 */
"SETTINGS_TIMEOUT", /* 0x4 */
"STREAM_CLOSED", /* 0x5 */
"FRAME_SIZE_ERROR", /* 0x6 */
"REFUSED_STREAM", /* 0x7 */
"CANCEL", /* 0x8 */
"COMPRESSION_ERROR", /* 0x9 */
"CONNECT_ERROR", /* 0xA */
"ENHANCE_YOUR_CALM", /* 0xB */
"INADEQUATE_SECURITY", /* 0xC */
"HTTP_1_1_REQUIRED" /* 0xD */
};
return (err < sizeof(str) / sizeof(str[0])) ? str[err] : "unknown";
#else
return nghttp2_http2_strerror(err);
#endif
}
/* /*
* The implementation of nghttp2_send_callback type. Here we write |data| with * The implementation of nghttp2_send_callback type. Here we write |data| with
* size |length| to the network and return the number of bytes actually * size |length| to the network and return the number of bytes actually
@ -838,7 +801,7 @@ static int on_stream_close(nghttp2_session *session, int32_t stream_id,
return 0; return 0;
} }
H2BUGF(infof(data_s, "on_stream_close(), %s (err %d), stream %u\n", H2BUGF(infof(data_s, "on_stream_close(), %s (err %d), stream %u\n",
http2_strerror(error_code), error_code, stream_id)); nghttp2_strerror(error_code), error_code, stream_id));
stream = data_s->req.protop; stream = data_s->req.protop;
if(!stream) if(!stream)
return NGHTTP2_ERR_CALLBACK_FAILURE; return NGHTTP2_ERR_CALLBACK_FAILURE;
@ -1138,8 +1101,7 @@ static ssize_t data_source_read_callback(nghttp2_session *session,
return nread; return nread;
} }
#if defined(NGHTTP2_HAS_ERROR_CALLBACK) && \ #if !defined(CURL_DISABLE_VERBOSE_STRINGS)
!defined(CURL_DISABLE_VERBOSE_STRINGS)
static int error_callback(nghttp2_session *session, static int error_callback(nghttp2_session *session,
const char *msg, const char *msg,
size_t len, size_t len,
@ -1257,9 +1219,7 @@ static CURLcode http2_init(struct connectdata *conn)
/* nghttp2_on_header_callback */ /* nghttp2_on_header_callback */
nghttp2_session_callbacks_set_on_header_callback(callbacks, on_header); nghttp2_session_callbacks_set_on_header_callback(callbacks, on_header);
#ifndef CURL_DISABLE_VERBOSE_STRINGS
nghttp2_session_callbacks_set_error_callback(callbacks, error_callback); nghttp2_session_callbacks_set_error_callback(callbacks, error_callback);
#endif
/* The nghttp2 session is not yet setup, do it */ /* The nghttp2 session is not yet setup, do it */
rc = nghttp2_session_client_new(&conn->proto.httpc.h2, callbacks, conn); rc = nghttp2_session_client_new(&conn->proto.httpc.h2, callbacks, conn);
@ -1457,7 +1417,7 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn,
} }
else if(httpc->error_code != NGHTTP2_NO_ERROR) { else if(httpc->error_code != NGHTTP2_NO_ERROR) {
failf(data, "HTTP/2 stream %d was not closed cleanly: %s (err %u)", failf(data, "HTTP/2 stream %d was not closed cleanly: %s (err %u)",
stream->stream_id, http2_strerror(httpc->error_code), stream->stream_id, nghttp2_strerror(httpc->error_code),
httpc->error_code); httpc->error_code);
*err = CURLE_HTTP2_STREAM; *err = CURLE_HTTP2_STREAM;
return -1; return -1;
@ -2264,7 +2224,6 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
} }
} }
#ifdef NGHTTP2_HAS_SET_LOCAL_WINDOW_SIZE
rv = nghttp2_session_set_local_window_size(httpc->h2, NGHTTP2_FLAG_NONE, 0, rv = nghttp2_session_set_local_window_size(httpc->h2, NGHTTP2_FLAG_NONE, 0,
HTTP2_HUGE_WINDOW_SIZE); HTTP2_HUGE_WINDOW_SIZE);
if(rv != 0) { if(rv != 0) {
@ -2272,7 +2231,6 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
nghttp2_strerror(rv), rv); nghttp2_strerror(rv), rv);
return CURLE_HTTP2; return CURLE_HTTP2;
} }
#endif
/* we are going to copy mem to httpc->inbuf. This is required since /* we are going to copy mem to httpc->inbuf. This is required since
mem is part of buffer pointed by stream->mem, and callbacks mem is part of buffer pointed by stream->mem, and callbacks