lib: #ifdef on USE_HTTP2 better

... as nghttp2 might not be the library that provides HTTP/2 support.

Closes #8661
This commit is contained in:
Daniel Stenberg 2022-04-01 13:45:38 +02:00
parent 266627b0bc
commit b716b5aa7e
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 18 additions and 19 deletions

View 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

View file

@ -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

View 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;

View 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

View 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)

View file

@ -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,