Skip to content

Commit

Permalink
alt-svc: enable by default
Browse files Browse the repository at this point in the history
[Remove CURLALTSVC_IMMEDIATELY]

alt-svc support is no longer considered experimental

Closes #5868
  • Loading branch information
bagder committed Sep 5, 2020
1 parent 6ecb63e commit dd2145e
Show file tree
Hide file tree
Showing 26 changed files with 48 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ stages:
torture:
name: torture
install: libnghttp2-dev
configure: --enable-debug --disable-shared --disable-threaded-resolver --enable-alt-svc
configure: --enable-debug --disable-shared --disable-threaded-resolver
tests: -n -t --shallow=40 !FTP
steps:
- script: sudo apt-get update && sudo apt-get install -y stunnel4 python-impacket libzstd-dev libbrotli-dev $(install)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
macosx-version-min: 10.9
- name: torture
install: nghttp2 openssl
configure: --enable-debug --disable-shared --disable-threaded-resolver --enable-alt-svc
configure: --enable-debug --disable-shared --disable-threaded-resolver
tflags: -n -t --shallow=25 !FTP
macosx-version-min: 10.9
- name: macOS 10.15
Expand Down
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
before_install:
- eval "$(gimme stable)"; gimme --list # Install latest Go (for boringssl)
- env:
- T=novalgrind QUICHE="yes" C="--with-ssl=$HOME/quiche/deps/boringssl/src --with-quiche=$HOME/quiche/target/release --enable-alt-svc" LD_LIBRARY_PATH=$HOME/quiche/target/release:/usr/local/lib
- T=novalgrind QUICHE="yes" C="--with-ssl=$HOME/quiche/deps/boringssl/src --with-quiche=$HOME/quiche/target/release" LD_LIBRARY_PATH=$HOME/quiche/target/release:/usr/local/lib
- OVERRIDE_CC="CC=gcc-8" OVERRIDE_CXX="CXX=g++-8"
addons:
apt:
Expand All @@ -110,7 +110,7 @@ jobs:
- libbrotli-dev
- libzstd-dev
- env:
- T=novalgrind NGTCP2=yes C="--with-ssl=$HOME/ngbuild --with-ngtcp2=$HOME/ngbuild --with-nghttp3=$HOME/ngbuild --enable-alt-svc" NOTESTS=
- T=novalgrind NGTCP2=yes C="--with-ssl=$HOME/ngbuild --with-ngtcp2=$HOME/ngbuild --with-nghttp3=$HOME/ngbuild" NOTESTS=
- OVERRIDE_CC="CC=gcc-8" OVERRIDE_CXX="CXX=g++-8"
addons:
apt:
Expand All @@ -121,7 +121,7 @@ jobs:
- libbrotli-dev
- libzstd-dev
- env:
- T=novalgrind NGTCP2=yes GNUTLS=yes C="PKG_CONFIG_PATH=$HOME/ngbuild --without-ssl --with-gnutls=$HOME/ngbuild --with-ngtcp2=$HOME/ngbuild --with-nghttp3=$HOME/ngbuild --enable-alt-svc" NOTESTS=
- T=novalgrind NGTCP2=yes GNUTLS=yes C="PKG_CONFIG_PATH=$HOME/ngbuild --without-ssl --with-gnutls=$HOME/ngbuild --with-ngtcp2=$HOME/ngbuild --with-nghttp3=$HOME/ngbuild" NOTESTS=
- OVERRIDE_CC="CC=gcc-8" OVERRIDE_CXX="CXX=g++-8"
addons:
apt:
Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:
- libbrotli-dev
- libzstd-dev
- env:
- T=debug C="--enable-alt-svc"
- T=debug C="--disable-alt-svc"
- *clang
compiler: clang
addons:
Expand Down Expand Up @@ -341,7 +341,7 @@ jobs:
- libbrotli-dev
- libzstd-dev
- env:
- T=debug C="--enable-alt-svc"
- T=debug C=""
- OVERRIDE_CC="CC=gcc-8" OVERRIDE_CXX="CXX=g++-8"
arch: arm64
addons:
Expand All @@ -359,7 +359,7 @@ jobs:
- zlib1g-dev

- env:
- T=debug C="--enable-alt-svc"
- T=debug C=""
- OVERRIDE_CC="CC=gcc-8" OVERRIDE_CXX="CXX=g++-8"
arch: ppc64le
addons:
Expand All @@ -377,7 +377,7 @@ jobs:
- zlib1g-dev

- env:
- T=debug C="--enable-alt-svc"
- T=debug C=""
- OVERRIDE_CC="CC=gcc-8" OVERRIDE_CXX="CXX=g++-8"
arch: s390x
addons:
Expand Down
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,10 @@ if(HTTP_ONLY)
set(CURL_DISABLE_GOPHER ON)
endif()

option(CURL_DISABLE_ALTSVC "to disable alt-svc support" OFF)
mark_as_advanced(CURL_DISABLE_ALTSVC)
option(CURL_DISABLE_COOKIES "to disable cookies support" OFF)
mark_as_advanced(CURL_DISABLE_COOKIES)

option(CURL_DISABLE_CRYPTO_AUTH "to disable cryptographic authentication" OFF)
mark_as_advanced(CURL_DISABLE_CRYPTO_AUTH)
option(CURL_DISABLE_VERBOSE_STRINGS "to disable verbose strings" OFF)
Expand Down Expand Up @@ -791,8 +792,6 @@ else()
unset(USE_UNIX_SOCKETS CACHE)
endif()

option(ENABLE_ALT_SVC "Enable alt-svc support" OFF)
set(USE_ALTSVC ${ENABLE_ALT_SVC})

#
# CA handling
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ environment:
BUILD_SYSTEM: autotools
TESTING: ON
DISABLED_TESTS: "!19 ~1056 !1233"
CONFIG_ARGS: "--enable-debug --enable-werror --enable-alt-svc --disable-threaded-resolver --disable-proxy"
CONFIG_ARGS: "--enable-debug --enable-werror --disable-threaded-resolver --disable-proxy"
- APPVEYOR_BUILD_WORKER_IMAGE: "Visual Studio 2019"
BUILD_SYSTEM: autotools
TESTING: ON
DISABLED_TESTS: "!19 !504 !704 !705 ~1056 !1233"
CONFIG_ARGS: "--enable-debug --enable-werror --enable-alt-svc --disable-threaded-resolver"
CONFIG_ARGS: "--enable-debug --enable-werror --disable-threaded-resolver"
- APPVEYOR_BUILD_WORKER_IMAGE: "Visual Studio 2019"
BUILD_SYSTEM: autotools
TESTING: ON
Expand Down
13 changes: 5 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4850,28 +4850,25 @@ AC_HELP_STRING([--disable-get-easy-options],[Disable curl_easy_options]),
dnl ************************************************************
dnl switch on/off alt-svc
dnl
curl_altsvc_msg="no (--enable-alt-svc)";
curl_altsvc_msg="enabled";
enable_altsvc="yes"
AC_MSG_CHECKING([whether to support alt-svc])
AC_ARG_ENABLE(alt-svc,
AC_HELP_STRING([--enable-alt-svc],[Enable alt-svc support])
AC_HELP_STRING([--disable-alt-svc],[Disable alt-svc support]),
[ case "$enableval" in
no)
AC_MSG_RESULT(no)
AC_DEFINE(CURL_DISABLE_ALTSVC, 1, [disable alt-svc])
curl_altsvc_msg="no";
enable_altsvc="no"
;;
*) AC_MSG_RESULT(yes)
curl_altsvc_msg="enabled";
enable_altsvc="yes"
;;
esac ],
AC_MSG_RESULT(no)
)

if test "$enable_altsvc" = "yes"; then
AC_DEFINE(USE_ALTSVC, 1, [to enable alt-svc])
experimental="$experimental alt-svc"
fi

dnl *************************************************************
dnl check whether ESNI support, if desired, is actually available
dnl
Expand Down
4 changes: 3 additions & 1 deletion docs/ALTSVC.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Alt-Svc

curl features **EXPERIMENTAL** support for the Alt-Svc: HTTP header.
curl features support for the Alt-Svc: HTTP header.

## Enable Alt-Svc in build

`./configure --enable-alt-svc`

(enabled by default since 7.73.0)

## Standard

[RFC 7838](https://tools.ietf.org/html/rfc7838)
Expand Down
4 changes: 4 additions & 0 deletions docs/CURL-DISABLE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Code defines to disable features and protocols

## CURL_DISABLE_ALTSVC

Disable support for Alt-Svc: HTTP headers.

## CURL_DISABLE_COOKIES

Disable support for HTTP cookies.
Expand Down
1 change: 0 additions & 1 deletion docs/EXPERIMENTAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ Experimental support in curl means:
## Experimental features right now

- HTTP/3 support and options
- alt-svc support and options
- CURLSSLOPT_NATIVE_CA (No configure option, feature built in when supported)
6 changes: 3 additions & 3 deletions docs/HTTP3.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Build curl
% git clone https://github.com/curl/curl
% cd curl
% ./buildconf
% LDFLAGS="-Wl,-rpath,<somewhere1>/lib" ./configure --with-ssl=<somewhere1> --with-nghttp3=<somewhere2> --with-ngtcp2=<somewhere3> --enable-alt-svc
% LDFLAGS="-Wl,-rpath,<somewhere1>/lib" ./configure --with-ssl=<somewhere1> --with-nghttp3=<somewhere2> --with-ngtcp2=<somewhere3>
% make

## Build with GnuTLS
Expand Down Expand Up @@ -105,7 +105,7 @@ Build curl
% git clone https://github.com/curl/curl
% cd curl
% ./buildconf
% ./configure --without-ssl --with-gnutls=<somewhere1> --with-nghttp3=<somewhere2> --with-ngtcp2=<somewhere3> --enable-alt-svc
% ./configure --without-ssl --with-gnutls=<somewhere1> --with-nghttp3=<somewhere2> --with-ngtcp2=<somewhere3>
% make

# quiche version
Expand All @@ -126,7 +126,7 @@ Build curl:
% git clone https://github.com/curl/curl
% cd curl
% ./buildconf
% ./configure LDFLAGS="-Wl,-rpath,$PWD/../quiche/target/release" --with-ssl=$PWD/../quiche/deps/boringssl/src --with-quiche=$PWD/../quiche/target/release --enable-alt-svc
% ./configure LDFLAGS="-Wl,-rpath,$PWD/../quiche/target/release" --with-ssl=$PWD/../quiche/deps/boringssl/src --with-quiche=$PWD/../quiche/target/release
% make

## Run
Expand Down
7 changes: 1 addition & 6 deletions docs/libcurl/opts/CURLOPT_ALTSVC.3
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,11 +29,6 @@ CURLOPT_ALTSVC \- set alt-svc cache file name

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ALTSVC, char *filename);
.fi
.SH EXPERIMENTAL
Warning: this feature is early code and is marked as experimental. It can only
be enabled by explicitly telling configure with \fB--enable-alt-svc\fP. You are
advised to not ship this in production before the experimental label is
removed.
.SH DESCRIPTION
Pass in a pointer to a \fIfilename\fP to instruct libcurl to use that file as
the Alt-Svc cache to read existing cache contents from and possibly also write
Expand Down
10 changes: 0 additions & 10 deletions docs/libcurl/opts/CURLOPT_ALTSVC_CTRL.3
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,13 @@ CURLOPT_ALTSVC_CTRL \- control alt-svc behavior
.nf
#include <curl/curl.h>

#define CURLALTSVC_IMMEDIATELY (1<<0)
#define CURLALTSVC_READONLYFILE (1<<2)
#define CURLALTSVC_H1 (1<<3)
#define CURLALTSVC_H2 (1<<4)
#define CURLALTSVC_H3 (1<<5)

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ALTSVC_CTRL, long bitmask);
.fi
.SH EXPERIMENTAL
Warning: this feature is early code and is marked as experimental. It can only
be enabled by explicitly telling configure with \fB--enable-alt-svc\fP. You are
advised to not ship this in production before the experimental label is
removed.
.SH DESCRIPTION
Populate the long \fIbitmask\fP with the correct set of features to instruct
libcurl how to handle Alt-Svc for the transfers using this handle.
Expand All @@ -50,10 +44,6 @@ origin is properly hosted over HTTPS. These requirements are there to make
sure both the source and the destination are legitimate.

Setting any bit will enable the alt-svc engine.
.IP "CURLALTSVC_IMMEDIATELY"
If an Alt-Svc: header is received, this instructs libcurl to switch to one of
those alternatives asap rather than to save it and use for the next
request. (Not currently supported).
.IP "CURLALTSVC_READONLYFILE"
Do not write the alt-svc cache back to the file specified with
\fICURLOPT_ALTSVC(3)\fP even if it gets updated. By default a file specified
Expand Down
1 change: 0 additions & 1 deletion docs/libcurl/symbols-in-versions
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
CURLALTSVC_H1 7.64.1
CURLALTSVC_H2 7.64.1
CURLALTSVC_H3 7.64.1
CURLALTSVC_IMMEDIATELY 7.64.1
CURLALTSVC_READONLYFILE 7.64.1
CURLAUTH_ANY 7.10.6
CURLAUTH_ANYSAFE 7.10.6
Expand Down
2 changes: 0 additions & 2 deletions include/curl/curl.h
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,6 @@ typedef enum {
#define CURLHEADER_SEPARATE (1<<0)

/* CURLALTSVC_* are bits for the CURLOPT_ALTSVC_CTRL option */
#define CURLALTSVC_IMMEDIATELY (1<<0)

#define CURLALTSVC_READONLYFILE (1<<2)
#define CURLALTSVC_H1 (1<<3)
#define CURLALTSVC_H2 (1<<4)
Expand Down
4 changes: 2 additions & 2 deletions lib/altsvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
#include "curl_setup.h"

#if !defined(CURL_DISABLE_HTTP) && defined(USE_ALTSVC)
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_ALTSVC)
#include <curl/curl.h>
#include "urldata.h"
#include "altsvc.h"
Expand Down Expand Up @@ -640,4 +640,4 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi,
return FALSE;
}

#endif /* CURL_DISABLE_HTTP || USE_ALTSVC */
#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_ALTSVC */
4 changes: 2 additions & 2 deletions lib/altsvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
***************************************************************************/
#include "curl_setup.h"

#if !defined(CURL_DISABLE_HTTP) && defined(USE_ALTSVC)
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_ALTSVC)
#include <curl/curl.h>
#include "llist.h"

Expand Down Expand Up @@ -74,5 +74,5 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi,
#else
/* disabled */
#define Curl_altsvc_save(a,b,c)
#endif /* CURL_DISABLE_HTTP || USE_ALTSVC */
#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_ALTSVC */
#endif /* HEADER_CURL_ALTSVC_H */
3 changes: 0 additions & 3 deletions lib/config-os400.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,6 @@
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME

/* Define to enable alt-svc support (experimental) */
#undef USE_ALTSVC

/* Define to enable HTTP3 support (experimental, requires NGTCP2 or QUICHE) */
#undef ENABLE_QUIC

Expand Down
4 changes: 2 additions & 2 deletions lib/curl_config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1014,8 +1014,8 @@ ${SIZEOF_TIME_T_CODE}
/* if Unix domain sockets are enabled */
#cmakedefine USE_UNIX_SOCKETS

/* to enable alt-svc */
#cmakedefine USE_ALTSVC 1
/* to disable alt-svc */
#cmakedefine CURL_DISABLE_ALTSVC 1

/* Define to 1 if you are building a Windows target with large file support. */
#cmakedefine USE_WIN32_LARGE_FILES 1
Expand Down
4 changes: 2 additions & 2 deletions lib/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -2516,7 +2516,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(result)
return result;

#ifdef USE_ALTSVC
#ifndef CURL_DISABLE_ALTSVC
if(conn->bits.altused && !Curl_checkheaders(conn, "Alt-Used")) {
altused = aprintf("Alt-Used: %s:%d\r\n",
conn->conn_to_host.name, conn->conn_to_port);
Expand Down Expand Up @@ -3990,7 +3990,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
}
}
}
#ifdef USE_ALTSVC
#ifndef CURL_DISABLE_ALTSVC
/* If enabled, the header is incoming and this is over HTTPS */
else if(data->asi && checkprefix("Alt-Svc:", headp) &&
((conn->handler->flags & PROTOPT_SSL) ||
Expand Down
4 changes: 2 additions & 2 deletions lib/rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

#include "curl_setup.h"

#if (!defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)) || \
defined(USE_ALTSVC)
#if (!defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)) && \
!defined(CURL_DISABLE_ALTSVC)

#include "curl_multibyte.h"
#include "timeval.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/setopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2847,7 +2847,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
data->set.trailer_data = va_arg(param, void *);
#endif
break;
#ifdef USE_ALTSVC
#ifndef CURL_DISABLE_ALTSVC
case CURLOPT_ALTSVC:
if(!data->asi) {
data->asi = Curl_altsvc_init();
Expand Down
4 changes: 2 additions & 2 deletions lib/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ CURLcode Curl_close(struct Curl_easy **datap)
Curl_dyn_free(&data->state.headerb);
Curl_safefree(data->state.ulbuf);
Curl_flush_cookies(data, TRUE);
#ifdef USE_ALTSVC
#ifndef CURL_DISABLE_ALTSVC
Curl_altsvc_save(data, data->asi, data->set.str[STRING_ALTSVC]);
Curl_altsvc_cleanup(data->asi);
data->asi = NULL;
Expand Down Expand Up @@ -3078,7 +3078,7 @@ static CURLcode parse_connect_to_slist(struct Curl_easy *data,
conn_to_host = conn_to_host->next;
}

#ifdef USE_ALTSVC
#ifndef CURL_DISABLE_ALTSVC
if(data->asi && !host && (port == -1) &&
((conn->handler->protocol == CURLPROTO_HTTPS) ||
#ifdef CURLDEBUG
Expand Down
2 changes: 1 addition & 1 deletion lib/urldata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,7 @@ struct Curl_easy {
NOTE that the 'cookie' field in the
UserDefined struct defines if the "engine"
is to be used or not. */
#ifdef USE_ALTSVC
#ifndef CURL_DISABLE_ALTSVC
struct altsvcinfo *asi; /* the alt-svc cache */
#endif
struct Progress progress; /* for all the progress meter data */
Expand Down
Loading

0 comments on commit dd2145e

Please sign in to comment.