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