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