CURLOPT_HSTSWRITEFUNCTION.3 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2020, 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. #include <curl/curl.h>
  28. CURLSTScode hstswrite(CURL *easy, struct curl_hstsentry *sts,
  29. struct curl_index *count, void *userp);
  30. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSWRITEFUNCTION, hstswrite);
  31. .SH EXPERIMENTAL
  32. Warning: this feature is early code and is marked as experimental. It can only
  33. be enabled by explicitly telling configure with \fB--enable-hsts\fP. You are
  34. advised to not ship this in production before the experimental label is
  35. removed.
  36. .SH DESCRIPTION
  37. Pass a pointer to your callback function, as the prototype shows above.
  38. This callback function gets called by libcurl repeatedly to allow the
  39. application to store the in-memory HSTS cache when libcurl is about to discard
  40. it.
  41. Set the \fIuserp\fP argument with the \fICURLOPT_HSTSWRITEDATA(3)\fP option or
  42. it will be NULL.
  43. When the callback is invoked, the \fIsts\fP pointer points to a populated
  44. struct: Read the host name to 'name' (it is 'namelen' bytes long and null
  45. terminated. The 'includeSubDomains' field is non-zero if the entry matches
  46. subdomains. The 'expire' string is a date stamp null-terminated string using
  47. the syntax YYYYMMDD HH:MM:SS.
  48. The callback should return \fICURLSTS_OK\fP if it succeeded and is prepared to
  49. be called again (for another host) or \fICURLSTS_DONE\fP if there's nothing
  50. more to do. It can also return \fICURLSTS_FAIL\fP to signal error.
  51. .SH DEFAULT
  52. NULL - no callback.
  53. .SH PROTOCOLS
  54. This feature is only used for HTTP(S) transfer.
  55. .SH EXAMPLE
  56. .nf
  57. {
  58. /* set HSTS read callback */
  59. curl_easy_setopt(curl, CURLOPT_HSTSWRITEFUNCTION, hstswrite);
  60. /* pass in suitable argument to the callback */
  61. curl_easy_setopt(curl, CURLOPT_HSTSWRITEDATA, &hstspreload[0]);
  62. result = curl_easy_perform(curl);
  63. }
  64. .fi
  65. .SH AVAILABILITY
  66. Added in 7.74.0
  67. .SH RETURN VALUE
  68. This will return CURLE_OK.
  69. .SH "SEE ALSO"
  70. .BR CURLOPT_HSTSWRITEDATA "(3), " CURLOPT_HSTSWRITEFUNCTION "(3), "
  71. .BR CURLOPT_HSTS "(3), " CURLOPT_HSTS_CTRL "(3), "