1CURLOPT_HSTSWRITEFUNCTION(3)curl_easy_setopt optionsCURLOPT_HSTSWRITEFUNCTION(3)
2
3
4

NAME

6       CURLOPT_HSTSWRITEFUNCTION - write callback for HSTS hosts
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       struct curl_hstsentry {
12         char *name;
13         size_t namelen;
14         unsigned int includeSubDomains:1;
15         char expire[18]; /* YYYYMMDD HH:MM:SS [null-terminated] */
16       };
17
18       struct curl_index {
19         size_t index; /* the provided entry's "index" or count */
20         size_t total; /* total number of entries to save */
21       };
22
23       CURLSTScode hstswrite(CURL *easy, struct curl_hstsentry *sts,
24                             struct curl_index *count, void *clientp);
25
26       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSWRITEFUNCTION, hstswrite);
27

DESCRIPTION

29       Pass a pointer to your callback function, as the prototype shows above.
30
31       This  callback  function gets called by libcurl repeatedly to allow the
32       application to store the in-memory HSTS cache when libcurl is about  to
33       discard it.
34
35       Set the clientp argument with the CURLOPT_HSTSWRITEDATA(3) option or it
36       will be NULL.
37
38       When the callback is invoked, the sts pointer  points  to  a  populated
39       struct: Read the host name to 'name' (it is namelen bytes long and null
40       terminated. The  includeSubDomains  field  is  non-zero  if  the  entry
41       matches  subdomains.  The expire string is a date stamp null-terminated
42       string using the syntax YYYYMMDD HH:MM:SS.
43
44       The callback should return CURLSTS_OK if it succeeded and  is  prepared
45       to  be called again (for another host) or CURLSTS_DONE if there's noth‐
46       ing more to do. It can also return CURLSTS_FAIL to signal error.
47
48       This option does not enable HSTS, you need to use  CURLOPT_HSTS_CTRL(3)
49       to do that.
50

DEFAULT

52       NULL - no callback.
53

PROTOCOLS

55       This feature is only used for HTTP(S) transfer.
56

EXAMPLE

58       {
59         /* set HSTS read callback */
60         curl_easy_setopt(curl, CURLOPT_HSTSWRITEFUNCTION, hstswrite);
61
62         /* pass in suitable argument to the callback */
63         curl_easy_setopt(curl, CURLOPT_HSTSWRITEDATA, &hstspreload[0]);
64
65         result = curl_easy_perform(curl);
66       }
67

AVAILABILITY

69       Added in 7.74.0
70

RETURN VALUE

72       This will return CURLE_OK.
73

SEE ALSO

75       CURLOPT_HSTSWRITEDATA(3),       CURLOPT_HSTSWRITEFUNCTION(3),      CUR‐
76       LOPT_HSTS(3), CURLOPT_HSTS_CTRL(3),
77
78
79
80libcurl 8.0.1                  February 07, 2023  CURLOPT_HSTSWRITEFUNCTION(3)
Impressum