CURLOPT_HSTSWRITEFUNCTION.3 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" **************************************************************************
  22. .\"
  23. .TH CURLOPT_HSTSWRITEFUNCTION 3 "14 Sep 2020" "libcurl 7.74.0" "curl_easy_setopt options"
  24. .SH NAME
  25. CURLOPT_HSTSWRITEFUNCTION \- write callback for HSTS hosts
  26. .SH SYNOPSIS
  27. .nf
  28. #include <curl/curl.h>
  29. struct curl_hstsentry {
  30. char *name;
  31. size_t namelen;
  32. unsigned int includeSubDomains:1;
  33. char expire[18]; /* YYYYMMDD HH:MM:SS [null-terminated] */
  34. };
  35. struct curl_index {
  36. size_t index; /* the provided entry's "index" or count */
  37. size_t total; /* total number of entries to save */
  38. };
  39. CURLSTScode hstswrite(CURL *easy, struct curl_hstsentry *sts,
  40. struct curl_index *count, void *userp);
  41. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSWRITEFUNCTION, hstswrite);
  42. .fi
  43. .SH DESCRIPTION
  44. Pass a pointer to your callback function, as the prototype shows above.
  45. This callback function gets called by libcurl repeatedly to allow the
  46. application to store the in-memory HSTS cache when libcurl is about to discard
  47. it.
  48. Set the \fIuserp\fP argument with the \fICURLOPT_HSTSWRITEDATA(3)\fP option or
  49. it will be NULL.
  50. When the callback is invoked, the \fIsts\fP pointer points to a populated
  51. struct: Read the host name to 'name' (it is 'namelen' bytes long and null
  52. terminated. The 'includeSubDomains' field is non-zero if the entry matches
  53. subdomains. The 'expire' string is a date stamp null-terminated string using
  54. the syntax YYYYMMDD HH:MM:SS.
  55. The callback should return \fICURLSTS_OK\fP if it succeeded and is prepared to
  56. be called again (for another host) or \fICURLSTS_DONE\fP if there's nothing
  57. more to do. It can also return \fICURLSTS_FAIL\fP to signal error.
  58. This option does not enable HSTS, you need to use \fICURLOPT_HSTS_CTRL(3)\fP to
  59. do that.
  60. .SH DEFAULT
  61. NULL - no callback.
  62. .SH PROTOCOLS
  63. This feature is only used for HTTP(S) transfer.
  64. .SH EXAMPLE
  65. .nf
  66. {
  67. /* set HSTS read callback */
  68. curl_easy_setopt(curl, CURLOPT_HSTSWRITEFUNCTION, hstswrite);
  69. /* pass in suitable argument to the callback */
  70. curl_easy_setopt(curl, CURLOPT_HSTSWRITEDATA, &hstspreload[0]);
  71. result = curl_easy_perform(curl);
  72. }
  73. .fi
  74. .SH AVAILABILITY
  75. Added in 7.74.0
  76. .SH RETURN VALUE
  77. This will return CURLE_OK.
  78. .SH "SEE ALSO"
  79. .BR CURLOPT_HSTSWRITEDATA "(3), " CURLOPT_HSTSWRITEFUNCTION "(3), "
  80. .BR CURLOPT_HSTS "(3), " CURLOPT_HSTS_CTRL "(3), "