CURLOPT_HSTS_CTRL.md (1659B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_HSTS_CTRL 5 Section: 3 6 Source: libcurl 7 Protocol: 8 - HTTP 9 See-also: 10 - CURLOPT_ALTSVC (3) 11 - CURLOPT_CONNECT_TO (3) 12 - CURLOPT_HSTS (3) 13 - CURLOPT_RESOLVE (3) 14 Added-in: 7.74.0 15 --- 16 17 # NAME 18 19 CURLOPT_HSTS_CTRL - control HSTS behavior 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 #define CURLHSTS_ENABLE (1<<0) 27 #define CURLHSTS_READONLYFILE (1<<1) 28 29 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTS_CTRL, long bitmask); 30 ~~~ 31 32 # DESCRIPTION 33 34 HSTS (HTTP Strict Transport Security) means that an HTTPS server can instruct 35 the client to not contact it again over clear-text HTTP for a certain period 36 into the future. libcurl then automatically redirects HTTP attempts to such 37 hosts to instead use HTTPS. This is done by libcurl retaining this knowledge 38 in an in-memory cache. 39 40 Populate the long *bitmask* with the correct set of features to instruct 41 libcurl how to handle HSTS for the transfers using this handle. 42 43 # BITS 44 45 ## CURLHSTS_ENABLE 46 47 Enable the in-memory HSTS cache for this handle. 48 49 ## CURLHSTS_READONLYFILE 50 51 Make the HSTS file (if specified) read-only - makes libcurl not save the cache 52 to the file when closing the handle. 53 54 # DEFAULT 55 56 0 57 58 # %PROTOCOLS% 59 60 # EXAMPLE 61 62 ~~~c 63 int main(void) 64 { 65 CURL *curl = curl_easy_init(); 66 if(curl) { 67 curl_easy_setopt(curl, CURLOPT_HSTS_CTRL, (long)CURLHSTS_ENABLE); 68 curl_easy_perform(curl); 69 } 70 } 71 ~~~ 72 73 # %AVAILABILITY% 74 75 # RETURN VALUE 76 77 curl_easy_setopt(3) returns a CURLcode indicating success or error. 78 79 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 80 libcurl-errors(3).