CURLOPT_POSTREDIR.3 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 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. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_POSTREDIR 3 "19 Jun 2014" libcurl libcurl
  26. .SH NAME
  27. CURLOPT_POSTREDIR \- how to act on an HTTP POST redirect
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTREDIR,
  32. long bitmask);
  33. .SH DESCRIPTION
  34. Pass a bitmask to control how libcurl acts on redirects after POSTs that get a
  35. 301, 302 or 303 response back. A parameter with bit 0 set (value
  36. \fBCURL_REDIR_POST_301\fP) tells the library to respect RFC 7231 (section
  37. 6.4.2 to 6.4.4) and not convert POST requests into GET requests when following
  38. a 301 redirection. Setting bit 1 (value \fBCURL_REDIR_POST_302\fP) makes
  39. libcurl maintain the request method after a 302 redirect whilst setting bit 2
  40. (value \fBCURL_REDIR_POST_303\fP) makes libcurl maintain the request method
  41. after a 303 redirect. The value \fBCURL_REDIR_POST_ALL\fP is a convenience
  42. define that sets all three bits.
  43. The non-RFC behavior is ubiquitous in web browsers, so the library does the
  44. conversion by default to maintain consistency. However, a server may require a
  45. POST to remain a POST after such a redirection. This option is meaningful only
  46. when setting \fICURLOPT_FOLLOWLOCATION(3)\fP.
  47. .SH DEFAULT
  48. 0
  49. .SH PROTOCOLS
  50. HTTP(S)
  51. .SH EXAMPLE
  52. .nf
  53. CURL *curl = curl_easy_init();
  54. if(curl) {
  55. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  56. /* a silly POST example */
  57. curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "data=true");
  58. /* example.com is redirected, so we tell libcurl to send POST on 301, 302 and
  59. 303 HTTP response codes */
  60. curl_easy_setopt(curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
  61. curl_easy_perform(curl);
  62. }
  63. .fi
  64. .SH AVAILABILITY
  65. Added in 7.17.1. This option was known as CURLOPT_POST301 up to 7.19.0 as it
  66. only supported the 301 then. CURL_REDIR_POST_303 was added in 7.26.0.
  67. .SH RETURN VALUE
  68. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  69. .SH "SEE ALSO"
  70. .BR CURLOPT_FOLLOWLOCATION "(3), " CURLOPT_POSTFIELDS "(3), "