1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_ALTSVC_CTRL
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_ALTSVC (3)
9  - CURLOPT_CONNECT_TO (3)
10  - CURLOPT_RESOLVE (3)
11---
12
13# NAME
14
15CURLOPT_ALTSVC_CTRL - control alt-svc behavior
16
17# SYNOPSIS
18
19~~~c
20#include <curl/curl.h>
21
22#define CURLALTSVC_READONLYFILE (1<<2)
23#define CURLALTSVC_H1           (1<<3)
24#define CURLALTSVC_H2           (1<<4)
25#define CURLALTSVC_H3           (1<<5)
26
27CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ALTSVC_CTRL, long bitmask);
28~~~
29
30# DESCRIPTION
31
32Populate the long *bitmask* with the correct set of features to instruct
33libcurl how to handle Alt-Svc for the transfers using this handle.
34
35libcurl only accepts Alt-Svc headers over a secure transport, meaning
36HTTPS. It also only completes a request to an alternative origin if that
37origin is properly hosted over HTTPS. These requirements are there to make
38sure both the source and the destination are legitimate.
39
40Alternative services are only used when setting up new connections. If there
41exists an existing connection to the host in the connection pool, then that is
42preferred.
43
44Setting any bit enables the alt-svc engine.
45
46## CURLALTSVC_READONLYFILE
47
48Do not write the alt-svc cache back to the file specified with
49CURLOPT_ALTSVC(3) even if it gets updated. By default a file specified
50with that option is read and written to as deemed necessary.
51
52## CURLALTSVC_H1
53
54Accept alternative services offered over HTTP/1.1.
55
56## CURLALTSVC_H2
57
58Accept alternative services offered over HTTP/2. This is only used if libcurl
59was also built to actually support HTTP/2, otherwise this bit is ignored.
60
61## CURLALTSVC_H3
62
63Accept alternative services offered over HTTP/3. This is only used if libcurl
64was also built to actually support HTTP/3, otherwise this bit is ignored.
65
66# DEFAULT
67
68Alt-Svc handling is disabled by default. If CURLOPT_ALTSVC(3) is set,
69CURLOPT_ALTSVC_CTRL(3) has a default value corresponding to
70CURLALTSVC_H1 | CURLALTSVC_H2 | CURLALTSVC_H3 - the HTTP/2 and HTTP/3 bits are
71only set if libcurl was built with support for those versions.
72
73# PROTOCOLS
74
75HTTPS
76
77# EXAMPLE
78
79~~~c
80int main(void)
81{
82  CURL *curl = curl_easy_init();
83  if(curl) {
84    curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, (long)CURLALTSVC_H1);
85    curl_easy_setopt(curl, CURLOPT_ALTSVC, "altsvc-cache.txt");
86    curl_easy_perform(curl);
87  }
88}
89~~~
90
91# AVAILABILITY
92
93Added in 7.64.1
94
95# RETURN VALUE
96
97Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
98