xref: /curl/docs/libcurl/opts/CURLOPT_HSTS_CTRL.md (revision e3fe0200)
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)
14---
15
16# NAME
17
18CURLOPT_HSTS_CTRL - control HSTS behavior
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25#define CURLHSTS_ENABLE       (1<<0)
26#define CURLHSTS_READONLYFILE (1<<1)
27
28CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTS_CTRL, long bitmask);
29~~~
30
31# DESCRIPTION
32
33HSTS (HTTP Strict Transport Security) means that an HTTPS server can instruct
34the client to not contact it again over clear-text HTTP for a certain period
35into the future. libcurl then automatically redirects HTTP attempts to such
36hosts to instead use HTTPS. This is done by libcurl retaining this knowledge
37in an in-memory cache.
38
39Populate the long *bitmask* with the correct set of features to instruct
40libcurl how to handle HSTS for the transfers using this handle.
41
42# BITS
43
44## CURLHSTS_ENABLE
45
46Enable the in-memory HSTS cache for this handle.
47
48## CURLHSTS_READONLYFILE
49
50Make the HSTS file (if specified) read-only - makes libcurl not save the cache
51to the file when closing the handle.
52
53# DEFAULT
54
550. HSTS is disabled by default.
56
57# EXAMPLE
58
59~~~c
60int main(void)
61{
62  CURL *curl = curl_easy_init();
63  if(curl) {
64    curl_easy_setopt(curl, CURLOPT_HSTS_CTRL, (long)CURLHSTS_ENABLE);
65    curl_easy_perform(curl);
66  }
67}
68~~~
69
70# AVAILABILITY
71
72Added in 7.74.0
73
74# RETURN VALUE
75
76Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
77