1CURLOPT_HSTSREADFUNCTION(3)curl_easy_setopt optionsCURLOPT_HSTSREADFUNCTION(3)
2
3
4
6 CURLOPT_HSTSREADFUNCTION - read callback for HSTS hosts
7
9 #include <curl/curl.h>
10
11 CURLSTScode hstsread(CURL *easy, struct curl_hstsentry *sts, void
12 *userp);
13
14 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSREADFUNCTION, hst‐
15 sread);
16
18 Pass a pointer to your callback function, as the prototype shows above.
19
20 This callback function gets called by libcurl repeatedly when it popu‐
21 lates the in-memory HSTS cache.
22
23 Set the userp argument with the CURLOPT_HSTSREADDATA(3) option or it
24 will be NULL.
25
26 When this callback is invoked, the sts pointer points to a populated
27 struct: Copy the host name to 'name' (no longer than 'namelen' bytes).
28 Make it null-terminated. Set 'includeSubDomains' to TRUE or FALSE. Set
29 'expire' to a date stamp or a zero length string for *forever* (wrong
30 date stamp format might cause the name to not get accepted)
31
32 The callback should return CURLSTS_OK if it returns a name and is pre‐
33 pared to be called again (for another host) or CURLSTS_DONE if it has
34 no entry to return. It can also return CURLSTS_FAIL to signal error.
35 Returning CURLSTS_FAIL will stop the transfer from being performed and
36 make CURLE_ABORTED_BY_CALLBACK get returned.
37
38 This option doesn't enable HSTS, you need to use CURLOPT_HSTS_CTRL(3)
39 to do that.
40
42 NULL - no callback.
43
45 This feature is only used for HTTP(S) transfer.
46
48 {
49 /* set HSTS read callback */
50 curl_easy_setopt(curl, CURLOPT_HSTSREADFUNCTION, hstsread);
51
52 /* pass in suitable argument to the callback */
53 curl_easy_setopt(curl, CURLOPT_HSTSREADDATA, &hstspreload[0]);
54
55 result = curl_easy_perform(curl);
56 }
57
59 Added in 7.74.0
60
62 This will return CURLE_OK.
63
65 CURLOPT_HSTSREADDATA(3), CURLOPT_HSTSWRITEFUNCTION(3), CURLOPT_HSTS(3),
66 CURLOPT_HSTS_CTRL(3),
67
68
69
70
71libcurl 7.79.1 September 16, 2021 CURLOPT_HSTSREADFUNCTION(3)