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