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 *userp);
12
13 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSREADFUNCTION, hstsread);
14
16 Pass a pointer to your callback function, as the prototype shows above.
17
18 This callback function gets called by libcurl repeatedly when it popu‐
19 lates the in-memory HSTS cache.
20
21 Set the userp argument with the CURLOPT_HSTSREADDATA(3) option or it
22 will be NULL.
23
24 When this callback is invoked, the sts pointer points to a populated
25 struct: Copy the host name to 'name' (no longer than 'namelen' bytes).
26 Make it null-terminated. Set 'includeSubDomains' to TRUE or FALSE. Set
27 'expire' to a date stamp or a zero length string for *forever* (wrong
28 date stamp format might cause the name to not get accepted)
29
30 The callback should return CURLSTS_OK if it returns a name and is pre‐
31 pared to be called again (for another host) or CURLSTS_DONE if it has
32 no entry to return. It can also return CURLSTS_FAIL to signal error.
33 Returning CURLSTS_FAIL will stop the transfer from being performed and
34 make CURLE_ABORTED_BY_CALLBACK get returned.
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_HSTSREADFUNCTION, hstsread);
49
50 /* pass in suitable argument to the callback */
51 curl_easy_setopt(curl, CURLOPT_HSTSREADDATA, &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_HSTSREADDATA(3), CURLOPT_HSTSWRITEFUNCTION(3), CURLOPT_HSTS(3),
64 CURLOPT_HSTS_CTRL(3),
65
66
67
68
69libcurl 7.82.0 November 26, 2021 CURLOPT_HSTSREADFUNCTION(3)