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