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