CURLOPT_HSTS.3 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. .\" generated by cd2nroff 0.1 from CURLOPT_HSTS.md
  2. .TH CURLOPT_HSTS 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_HSTS \- HSTS cache filename
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTS, char *filename);
  9. .fi
  10. .SH DESCRIPTION
  11. Make the \fIfilename\fP point to a filename to load an existing HSTS cache
  12. from, and to store the cache in when the easy handle is closed. Setting a file
  13. name with this option also enables HSTS for this handle (the equivalent of
  14. setting \fICURLHSTS_ENABLE\fP with \fICURLOPT_HSTS_CTRL(3)\fP).
  15. If the given file does not exist or contains no HSTS entries at startup, the
  16. HSTS cache simply starts empty. Setting the filename to NULL or "" only
  17. enables HSTS without reading from or writing to any file.
  18. If this option is set multiple times, libcurl loads cache entries from each
  19. given file but only stores the last used name for later writing.
  20. .SH FILE FORMAT
  21. The HSTS cache is saved to and loaded from a text file with one entry per
  22. physical line. Each line in the file has the following format:
  23. [host] [stamp]
  24. [host] is the domain name for the entry and the name is dot\-prefixed if it is
  25. an entry valid for all subdomains to the name as well or only for the exact
  26. name.
  27. [stamp] is the time (in UTC) when the entry expires and it uses the format
  28. \&"YYYYMMDD HH:MM:SS".
  29. Lines starting with "#" are treated as comments and are ignored. There is
  30. currently no length or size limit.
  31. .SH DEFAULT
  32. NULL, no filename
  33. .SH PROTOCOLS
  34. This functionality affects http only
  35. .SH EXAMPLE
  36. .nf
  37. int main(void)
  38. {
  39. CURL *curl = curl_easy_init();
  40. if(curl) {
  41. curl_easy_setopt(curl, CURLOPT_HSTS, "/home/user/.hsts-cache");
  42. curl_easy_perform(curl);
  43. }
  44. }
  45. .fi
  46. .SH AVAILABILITY
  47. Added in curl 7.74.0
  48. .SH RETURN VALUE
  49. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  50. .SH SEE ALSO
  51. .BR CURLOPT_ALTSVC (3),
  52. .BR CURLOPT_HSTS_CTRL (3),
  53. .BR CURLOPT_RESOLVE (3)