1CURLOPT_HSTSWRITEFUNCTION(3)curl_easy_setopt optionsCURLOPT_HSTSWRITEFUNCTION(3)
2
3
4
6 CURLOPT_HSTSWRITEFUNCTION - write callback for HSTS hosts
7
9 #include <curl/curl.h>
10
11 CURLSTScode hstswrite(CURL *easy, struct curl_hstsentry *sts,
12 struct curl_index *count, void *userp);
13
14 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSWRITEFUNCTION, hstswrite);
15
17 Pass a pointer to your callback function, as the prototype shows above.
18
19 This callback function gets called by libcurl repeatedly to allow the
20 application to store the in-memory HSTS cache when libcurl is about to
21 discard it.
22
23 Set the userp argument with the CURLOPT_HSTSWRITEDATA(3) option or it
24 will be NULL.
25
26 When the callback is invoked, the sts pointer points to a populated
27 struct: Read the host name to 'name' (it is 'namelen' bytes long and
28 null terminated. The 'includeSubDomains' field is non-zero if the entry
29 matches subdomains. The 'expire' string is a date stamp null-terminated
30 string using the syntax YYYYMMDD HH:MM:SS.
31
32 The callback should return CURLSTS_OK if it succeeded and is prepared
33 to be called again (for another host) or CURLSTS_DONE if there's noth‐
34 ing more to do. It can also return CURLSTS_FAIL to signal error.
35
36 This option does not enable HSTS, you need to use CURLOPT_HSTS_CTRL(3)
37 to do that.
38
40 NULL - no callback.
41
43 This feature is only used for HTTP(S) transfer.
44
46 {
47 /* set HSTS read callback */
48 curl_easy_setopt(curl, CURLOPT_HSTSWRITEFUNCTION, hstswrite);
49
50 /* pass in suitable argument to the callback */
51 curl_easy_setopt(curl, CURLOPT_HSTSWRITEDATA, &hstspreload[0]);
52
53 result = curl_easy_perform(curl);
54 }
55
57 Added in 7.74.0
58
60 This will return CURLE_OK.
61
63 CURLOPT_HSTSWRITEDATA(3), CURLOPT_HSTSWRITEFUNCTION(3), CUR‐
64 LOPT_HSTS(3), CURLOPT_HSTS_CTRL(3),
65
66
67
68libcurl 7.82.0 November 26, 2021 CURLOPT_HSTSWRITEFUNCTION(3)