1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_ALTSVC
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_ALTSVC_CTRL (3)
9  - CURLOPT_CONNECT_TO (3)
10  - CURLOPT_COOKIEFILE (3)
11  - CURLOPT_RESOLVE (3)
12---
13<!-- markdown-link-check-disable -->
14# NAME
15
16CURLOPT_ALTSVC - alt-svc cache file name
17
18# SYNOPSIS
19
20~~~c
21#include <curl/curl.h>
22
23CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ALTSVC, char *filename);
24~~~
25
26# DESCRIPTION
27
28Pass in a pointer to a *filename* to instruct libcurl to use that file as
29the Alt-Svc cache to read existing cache contents from and possibly also write
30it back to after a transfer, unless **CURLALTSVC_READONLYFILE** is set in
31CURLOPT_ALTSVC_CTRL(3).
32
33Specify a blank filename ("") to make libcurl not load from a file at all.
34
35# DEFAULT
36
37NULL. The alt-svc cache is not read nor written to file.
38
39# PROTOCOLS
40
41HTTPS
42
43# EXAMPLE
44
45~~~c
46int main(void)
47{
48  CURL *curl = curl_easy_init();
49  if(curl) {
50    curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, CURLALTSVC_H1);
51    curl_easy_setopt(curl, CURLOPT_ALTSVC, "altsvc-cache.txt");
52    curl_easy_perform(curl);
53  }
54}
55~~~
56
57# FILE FORMAT
58
59A text based file with one line per alt-svc entry and each line consists of
60nine space-separated fields.
61
62An example line could look like
63
64    h2 www.example.com 8443 h3 second.example.com 443 "20190808 06:18:37" 1 0
65
66The fields of that line are:
67
68## h2
69
70ALPN id for the source origin
71
72## www.example.comp
73
74Hostname for the source origin
75
76## 8443
77
78Port number for the source origin
79
80## h3
81
82ALPN id for the destination host
83
84## second.example.com
85
86Hostname for the destination host
87
88## 443
89
90Port number for the destination host
91
92## 2019*
93
94Expiration date and time of this entry within double quotes. The date format
95is "YYYYMMDD HH:MM:SS" and the time zone is GMT.
96
97## 1
98
99Boolean (1 or 0) if "persist" was set for this entry
100
101## 0
102
103Integer priority value (not currently used)
104
105# AVAILABILITY
106
107Added in 7.64.1
108
109# RETURN VALUE
110
111Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
112