From: Arran Cudbard-Bell Date: Wed, 13 Mar 2019 11:54:45 +0000 (+0800) Subject: Fix HTTP 2.0 checks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0434cf66ed4220fd031d17d437fccdae9d957cd0;p=thirdparty%2Ffreeradius-server.git Fix HTTP 2.0 checks --- diff --git a/src/modules/rlm_rest/rest.h b/src/modules/rlm_rest/rest.h index 6d0e352946b..21b348518ad 100644 --- a/src/modules/rlm_rest/rest.h +++ b/src/modules/rlm_rest/rest.h @@ -29,6 +29,15 @@ RCSIDH(other_h, "$Id$") #include "config.h" #define CURL_NO_OLDIES 1 + +/* + * We have to use this as curl uses lots of enums + */ +#ifndef CURL_AT_LEAST_VERSION +# define CURL_VERSION_BITS(x, y, z) ((x) << 16 | (y) << 8 | z) +# define CURL_AT_LEAST_VERSION(x, y, z) (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) +#endif + #include /* diff --git a/src/modules/rlm_rest/rlm_rest.c b/src/modules/rlm_rest/rlm_rest.c index 1bea094bf77..f116108f326 100644 --- a/src/modules/rlm_rest/rlm_rest.c +++ b/src/modules/rlm_rest/rlm_rest.c @@ -38,15 +38,18 @@ static FR_NAME_NUMBER const http_negotiation_table[] = { ///< libcurl will use whatever it thinks fit. { "1.0", CURL_HTTP_VERSION_1_0 }, //!< Enforce HTTP 1.0 requests. { "1.1", CURL_HTTP_VERSION_1_1 }, //!< Enforce HTTP 1.1 requests. -#ifdef CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE +/* + * These are all enum values + */ +#if CURL_AT_LEAST_VERSION(7,49,0) { "2.0", CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE }, //!< Enforce HTTP 2.0 requests. #endif -#ifdef CURL_HTTP_VERSION_2_0 +#if CURL_AT_LEAST_VERSION(7,33,0) { "2.0+auto", CURL_HTTP_VERSION_2_0 }, //!< Attempt HTTP 2 requests. libcurl will fall back ///< to HTTP 1.1 if HTTP 2 can't be negotiated with the ///< server. (Added in 7.33.0) #endif -#ifdef CURL_HTTP_VERSION_2TLS +#if CURL_AT_LEAST_VERSION(7,47,0) { "2.0+tls", CURL_HTTP_VERSION_2TLS }, //!< Attempt HTTP 2 over TLS (HTTPS) only. ///< libcurl will fall back to HTTP 1.1 if HTTP 2 ///< can't be negotiated with the HTTPS server.