xref: /curl/docs/libcurl/opts/CURLOPT_HSTS_CTRL.md (revision 5a488251)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_HSTS_CTRL
5Section: 3
6Source: libcurl
7Protocol:
8  - HTTP
9See-also:
10  - CURLOPT_ALTSVC (3)
11  - CURLOPT_CONNECT_TO (3)
12  - CURLOPT_HSTS (3)
13  - CURLOPT_RESOLVE (3)
14Added-in: 7.74.0
15---
16
17# NAME
18
19CURLOPT_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
29CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTS_CTRL, long bitmask);
30~~~
31
32# DESCRIPTION
33
34HSTS (HTTP Strict Transport Security) means that an HTTPS server can instruct
35the client to not contact it again over clear-text HTTP for a certain period
36into the future. libcurl then automatically redirects HTTP attempts to such
37hosts to instead use HTTPS. This is done by libcurl retaining this knowledge
38in an in-memory cache.
39
40Populate the long *bitmask* with the correct set of features to instruct
41libcurl how to handle HSTS for the transfers using this handle.
42
43# BITS
44
45## CURLHSTS_ENABLE
46
47Enable the in-memory HSTS cache for this handle.
48
49## CURLHSTS_READONLYFILE
50
51Make the HSTS file (if specified) read-only - makes libcurl not save the cache
52to the file when closing the handle.
53
54# DEFAULT
55
560
57
58# %PROTOCOLS%
59
60# EXAMPLE
61
62~~~c
63int 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
77Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
78