CURLOPT_HSTSREADFUNCTION.3 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_HSTSREADFUNCTION 3 "14 Sep 2020" "libcurl 7.74.0" "curl_easy_setopt options"
  24. .SH NAME
  25. CURLOPT_HSTSREADFUNCTION \- read 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. CURLSTScode hstsread(CURL *easy, struct curl_hstsentry *sts, void *userp);
  36. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSREADFUNCTION, hstsread);
  37. .fi
  38. .SH DESCRIPTION
  39. Pass a pointer to your callback function, as the prototype shows above.
  40. This callback function gets called by libcurl repeatedly when it populates the
  41. in-memory HSTS cache.
  42. Set the \fIuserp\fP argument with the \fICURLOPT_HSTSREADDATA(3)\fP option or
  43. it will be NULL.
  44. When this callback is invoked, the \fIsts\fP pointer points to a populated
  45. struct: Copy the host name to 'name' (no longer than 'namelen' bytes). Make it
  46. null-terminated. Set 'includeSubDomains' to TRUE or FALSE. Set 'expire' to a
  47. date stamp or a zero length string for *forever* (wrong date stamp format
  48. might cause the name to not get accepted)
  49. The callback should return \fICURLSTS_OK\fP if it returns a name and is
  50. prepared to be called again (for another host) or \fICURLSTS_DONE\fP if it has
  51. no entry to return. It can also return \fICURLSTS_FAIL\fP to signal
  52. error. Returning \fICURLSTS_FAIL\fP will stop the transfer from being
  53. performed and make \fICURLE_ABORTED_BY_CALLBACK\fP get returned.
  54. This option does not enable HSTS, you need to use \fICURLOPT_HSTS_CTRL(3)\fP to
  55. do that.
  56. .SH DEFAULT
  57. NULL - no callback.
  58. .SH PROTOCOLS
  59. This feature is only used for HTTP(S) transfer.
  60. .SH EXAMPLE
  61. .nf
  62. {
  63. /* set HSTS read callback */
  64. curl_easy_setopt(curl, CURLOPT_HSTSREADFUNCTION, hstsread);
  65. /* pass in suitable argument to the callback */
  66. curl_easy_setopt(curl, CURLOPT_HSTSREADDATA, &hstspreload[0]);
  67. result = curl_easy_perform(curl);
  68. }
  69. .fi
  70. .SH AVAILABILITY
  71. Added in 7.74.0
  72. .SH RETURN VALUE
  73. This will return CURLE_OK.
  74. .SH "SEE ALSO"
  75. .BR CURLOPT_HSTSREADDATA "(3), " CURLOPT_HSTSWRITEFUNCTION "(3), "
  76. .BR CURLOPT_HSTS "(3), " CURLOPT_HSTS_CTRL "(3), "