aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-02-21 11:30:05 +0100
committerDaniel Stenberg <daniel@haxx.se>2020-02-21 16:54:47 +0100
commit5808a0d0f5ea0399d4a2a22285f78c66f302c173 (patch)
tree826555e519dcce95f26cf0f09d7fcb32bb697948
parent3a34b930aaa883d5343d19acbc01e969e1e59c72 (diff)
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
-rwxr-xr-xconfigure.ac8
-rw-r--r--docs/INTERNALS.md2
-rw-r--r--lib/http2.c52
3 files changed, 10 insertions, 52 deletions
diff --git a/configure.ac b/configure.ac
index 7a6aa5303..bde7d8853 100755
--- a/configure.ac
+++ b/configure.ac
@@ -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
# 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"
LIBS="$LIB_H2 $LIBS"
- # use nghttp2_option_set_no_recv_client_magic to require nghttp2
- # >= 1.0.0
- AC_CHECK_LIB(nghttp2, nghttp2_option_set_no_recv_client_magic,
+ # use nghttp2_session_set_local_window_size to require nghttp2
+ # >= 1.12.0
+ AC_CHECK_LIB(nghttp2, nghttp2_session_set_local_window_size,
[
AC_CHECK_HEADERS(nghttp2/nghttp2.h,
curl_h2_msg="enabled (nghttp2)"
diff --git a/docs/INTERNALS.md b/docs/INTERNALS.md
index 9ae722898..9fb0733bb 100644
--- a/docs/INTERNALS.md
+++ b/docs/INTERNALS.md
@@ -97,7 +97,7 @@ Dependencies
- NSS 3.14.x
- PolarSSL 1.3.0
- Heimdal ?
- - nghttp2 1.0.0
+ - nghttp2 1.12.0
Operating Systems
-----------------
diff --git a/lib/http2.c b/lib/http2.c
index 690a537bf..dffc7a254 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -43,19 +43,11 @@
#define H2_BUFSIZE 32768
-#if (NGHTTP2_VERSION_NUM < 0x010000)
+#if (NGHTTP2_VERSION_NUM < 0x010c00)
#error too old nghttp2 version, upgrade!
#endif
-#if (NGHTTP2_VERSION_NUM > 0x010800)
-#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
+#ifdef CURL_DISABLE_VERBOSE_STRINGS
#define nghttp2_session_callbacks_set_error_callback(x,y)
#endif
@@ -344,35 +336,6 @@ int Curl_http2_ver(char *p, size_t len)
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
* 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;
}
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;
if(!stream)
return NGHTTP2_ERR_CALLBACK_FAILURE;
@@ -1138,8 +1101,7 @@ static ssize_t data_source_read_callback(nghttp2_session *session,
return nread;
}
-#if defined(NGHTTP2_HAS_ERROR_CALLBACK) && \
- !defined(CURL_DISABLE_VERBOSE_STRINGS)
+#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
static int error_callback(nghttp2_session *session,
const char *msg,
size_t len,
@@ -1257,9 +1219,7 @@ static CURLcode http2_init(struct connectdata *conn)
/* nghttp2_on_header_callback */
nghttp2_session_callbacks_set_on_header_callback(callbacks, on_header);
-#ifndef CURL_DISABLE_VERBOSE_STRINGS
nghttp2_session_callbacks_set_error_callback(callbacks, error_callback);
-#endif
/* The nghttp2 session is not yet setup, do it */
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) {
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);
*err = CURLE_HTTP2_STREAM;
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,
HTTP2_HUGE_WINDOW_SIZE);
if(rv != 0) {
@@ -2272,7 +2231,6 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
nghttp2_strerror(rv), rv);
return CURLE_HTTP2;
}
-#endif
/* we are going to copy mem to httpc->inbuf. This is required since
mem is part of buffer pointed by stream->mem, and callbacks