From: Daniel Stenberg Date: Fri, 1 Apr 2022 11:45:38 +0000 (+0200) Subject: lib: #ifdef on USE_HTTP2 better X-Git-Tag: curl-7_83_0~78 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b716b5aa7e3956c30d7ef38a8104715f4b956672;p=thirdparty%2Fcurl.git lib: #ifdef on USE_HTTP2 better ... as nghttp2 might not be the library that provides HTTP/2 support. Closes #8661 --- diff --git a/lib/altsvc.c b/lib/altsvc.c index 242733bfd7..759e862c82 100644 --- a/lib/altsvc.c +++ b/lib/altsvc.c @@ -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 diff --git a/lib/doh.c b/lib/doh.c index 292f5dc667..4aef8b266a 100644 --- 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 diff --git a/lib/http.c b/lib/http.c index 63cc748e8b..dd0d9879e3 100644 --- a/lib/http.c +++ b/lib/http.c @@ -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; diff --git a/lib/setopt.c b/lib/setopt.c index 8e1bf12791..8bfeec37ae 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -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 diff --git a/lib/transfer.c b/lib/transfer.c index 61e42fa0cb..79b6b7521c 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -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) diff --git a/lib/url.c b/lib/url.c index a56e4b093d..c55a83c0ec 100644 --- 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,