]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib: #ifdef on USE_HTTP2 better
authorDaniel Stenberg <daniel@haxx.se>
Fri, 1 Apr 2022 11:45:38 +0000 (13:45 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 1 Apr 2022 11:45:52 +0000 (13:45 +0200)
... as nghttp2 might not be the library that provides HTTP/2 support.

Closes #8661

lib/altsvc.c
lib/doh.c
lib/http.c
lib/setopt.c
lib/transfer.c
lib/url.c

index 242733bfd73fe9c911017fcaadc026e093b184ed..759e862c822e9be5e398a5375f3c47cefc02d1a5 100644 (file)
@@ -264,7 +264,7 @@ struct altsvcinfo *Curl_altsvc_init(void)
 
   /* set default behavior */
   asi->flags = CURLALTSVC_H1
-#ifdef USE_NGHTTP2
+#ifdef USE_HTTP2
     | CURLALTSVC_H2
 #endif
 #ifdef ENABLE_QUIC
index 292f5dc667fd5fa23a062e5a48a4ccd7e31e4d0b..4aef8b266a3c054d09f2a7261f5ff69e8999eb49 100644 (file)
--- a/lib/doh.c
+++ b/lib/doh.c
@@ -252,7 +252,7 @@ static CURLcode dohprobe(struct Curl_easy *data,
     ERROR_CHECK_SETOPT(CURLOPT_POSTFIELDS, p->dohbuffer);
     ERROR_CHECK_SETOPT(CURLOPT_POSTFIELDSIZE, (long)p->dohlen);
     ERROR_CHECK_SETOPT(CURLOPT_HTTPHEADER, headers);
-#ifdef USE_NGHTTP2
+#ifdef USE_HTTP2
     ERROR_CHECK_SETOPT(CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
 #endif
 #ifndef CURLDEBUG
index 63cc748e8b97b95d48ff44dfaa52216ec45d6005..dd0d9879e3117b8d809366cab4ddb32e9342fb94 100644 (file)
@@ -4228,10 +4228,10 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
           switch(httpversion) {
           case 10:
           case 11:
-#if defined(USE_NGHTTP2) || defined(USE_HYPER)
+#ifdef USE_HTTP2
           case 20:
 #endif
-#if defined(ENABLE_QUIC)
+#ifdef ENABLE_QUIC
           case 30:
 #endif
             conn->httpversion = (unsigned char)httpversion;
index 8e1bf12791f9335a4869311b96af7d1d1ec9082c..8bfeec37ae6f8a4b87daa38e25c2641452497b60 100644 (file)
@@ -890,7 +890,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
       ;
     else
 #endif
-#if !defined(USE_NGHTTP2) && !defined(USE_HYPER)
+#ifndef USE_HTTP2
     if(arg >= CURL_HTTP_VERSION_2)
       return CURLE_UNSUPPORTED_PROTOCOL;
 #else
index 61e42fa0cb7ef061f176bbbe97c5e8f3bf45d5dc..79b6b7521c8b70c9bda18f4538226189ae934172 100644 (file)
@@ -460,7 +460,7 @@ static int data_pending(const struct Curl_easy *data)
   /* in the case of libssh2, we can never be really sure that we have emptied
      its internal buffers so we MUST always try until we get EAGAIN back */
   return conn->handler->protocol&(CURLPROTO_SCP|CURLPROTO_SFTP) ||
-#if defined(USE_NGHTTP2)
+#ifdef USE_NGHTTP2
     /* For HTTP/2, we may read up everything including response body
        with header fields in Curl_http_readwrite_headers. If no
        content-length is provided, curl waits for the connection
@@ -543,15 +543,14 @@ static CURLcode readwrite_data(struct Curl_easy *data,
 
     if(
 #ifdef USE_NGHTTP2
-       /* For HTTP/2, read data without caring about the content
-          length. This is safe because body in HTTP/2 is always
-          segmented thanks to its framing layer. Meanwhile, we have to
-          call Curl_read to ensure that http2_handle_stream_close is
-          called when we read all incoming bytes for a particular
-          stream. */
-       !is_http2 &&
+      /* For HTTP/2, read data without caring about the content length. This
+         is safe because body in HTTP/2 is always segmented thanks to its
+         framing layer. Meanwhile, we have to call Curl_read to ensure that
+         http2_handle_stream_close is called when we read all incoming bytes
+         for a particular stream. */
+      !is_http2 &&
 #endif
-       k->size != -1 && !k->header) {
+      k->size != -1 && !k->header) {
       /* make sure we don't read too much */
       curl_off_t totalleft = k->size - k->bytecount;
       if(totalleft < (curl_off_t)bytestoread)
index a56e4b093da32e3010fb695c9226a43dd4cc2fdf..c55a83c0ec80b1e19406e0104c61798b91e7dd6d 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -620,7 +620,7 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
   set->maxlifetime_conn = 0;
   set->http09_allowed = FALSE;
   set->httpwant =
-#ifdef USE_NGHTTP2
+#ifdef USE_HTTP2
     CURL_HTTP_VERSION_2TLS
 #else
     CURL_HTTP_VERSION_1_1
@@ -3281,16 +3281,16 @@ static CURLcode parse_connect_to_slist(struct Curl_easy *data,
     bool hit;
     struct altsvc *as;
     const int allowed_versions = ( ALPN_h1
-#ifdef USE_NGHTTP2
-      | ALPN_h2
+#ifdef USE_HTTP2
+                                   | ALPN_h2
 #endif
 #ifdef ENABLE_QUIC
-      | ALPN_h3
+                                   | ALPN_h3
 #endif
       ) & data->asi->flags;
 
     host = conn->host.rawalloc;
-#ifdef USE_NGHTTP2
+#ifdef USE_HTTP2
     /* with h2 support, check that first */
     srcalpnid = ALPN_h2;
     hit = Curl_altsvc_lookup(data->asi,