• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
14Added-in: 7.64.1
15---
16<!-- markdown-link-check-disable -->
17# NAME
18
19CURLOPT_ALTSVC - alt-svc cache filename
20
21# SYNOPSIS
22
23~~~c
24#include <curl/curl.h>
25
26CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ALTSVC, char *filename);
27~~~
28
29# DESCRIPTION
30
31Pass in a pointer to a *filename* to instruct libcurl to use that file as
32the Alt-Svc cache to read existing cache contents from and possibly also write
33it back to after a transfer, unless **CURLALTSVC_READONLYFILE** is set in
34CURLOPT_ALTSVC_CTRL(3).
35
36Specify a blank filename ("") to make libcurl not load from a file at all.
37
38The application does not have to keep the string around after setting this
39option.
40
41Using this option multiple times makes the last set string override the
42previous ones. Set it to NULL to disable its use again.
43
44# SECURITY CONCERNS
45
46libcurl cannot fully protect against attacks where an attacker has write
47access to the same directory where it is directed to save files. This is
48particularly sensitive if you save files using elevated privileges.
49
50# DEFAULT
51
52NULL. The alt-svc cache is not read nor written to file.
53
54# %PROTOCOLS%
55
56# EXAMPLE
57
58~~~c
59int main(void)
60{
61  CURL *curl = curl_easy_init();
62  if(curl) {
63    curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, CURLALTSVC_H1);
64    curl_easy_setopt(curl, CURLOPT_ALTSVC, "altsvc-cache.txt");
65    curl_easy_perform(curl);
66  }
67}
68~~~
69
70# FILE FORMAT
71
72A text based file with one line per alt-svc entry and each line consists of
73nine space-separated fields.
74
75An example line could look like
76
77    h2 www.example.com 8443 h3 second.example.com 443 "20190808 06:18:37" 1 0
78
79The fields of that line are:
80
81## h2
82
83ALPN id for the source origin
84
85## www.example.comp
86
87Hostname for the source origin
88
89## 8443
90
91Port number for the source origin
92
93## h3
94
95ALPN id for the destination host
96
97## second.example.com
98
99Hostname for the destination host
100
101## 443
102
103Port number for the destination host
104
105## 2019*
106
107Expiration date and time of this entry within double quotes. The date format
108is "YYYYMMDD HH:MM:SS" and the time zone is GMT.
109
110## 1
111
112Boolean (1 or 0) if "persist" was set for this entry
113
114## 0
115
116Integer priority value (not currently used)
117
118# %AVAILABILITY%
119
120# RETURN VALUE
121
122curl_easy_setopt(3) returns a CURLcode indicating success or error.
123
124CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
125libcurl-errors(3).
126