CURLOPT_FOLLOWLOCATION: add a CURLFOLLOW_NO_CUSTOMREQUEST bit

With this change, the argument passed to the CURLOPT_FOLLOWLOCATION
option is treated as a bitmask instead of just a long. If the new
CURLFOLLOW_NO_CUSTOMREQUEST bit is set in the bitmask, it means that
libcurl will NOT allow a custom method override the HTTP request method
after a redirect is followed. As is otherwise the default behavior (that
surprises many users).

This change is forward compatible because CURLOPT_FOLLOWLOCATION has
been documented to accept the exact value of '1' to enable redirect
following and therefore the other bits were left unused and
undefined. We now add value to another bit. Starting in 7.66.0, the
value 1 and the first bit still enables plain redirect following but the
second bit adds more meaning.

This change is backward compatible in the following way: setting the
CURLFOLLOW_NO_CUSTOMREQUEST bit in a program that still uses an older
libcurl installation at run-tim will have no effect. This is because
older libcurl code checked if the value was non-zero and then enabled
redirect following. Of course older libcurl will always let the set
CURLOPT_CUSTOMREQUEST string override the method, disregarding what the
HTTP response code suggests.

Test 1589 added to verify the functionality.
11 files changed
tree: 50bd6e2fa1073aa6562a8ab0889307697b8eb4b5
  1. .cirrus.yml
  2. .dir-locals.el
  3. .gitattributes
  4. .github/
  5. .gitignore
  6. .lgtm.yml
  7. .mailmap
  8. .travis-iconv-env.sh
  9. .travis.yml
  10. CHANGES
  11. CMake/
  12. CMakeLists.txt
  13. COPYING
  14. GIT-INFO
  15. MacOSX-Framework
  16. Makefile.am
  17. Makefile.dist
  18. README
  19. README.md
  20. RELEASE-NOTES
  21. SECURITY.md
  22. acinclude.m4
  23. appveyor.yml
  24. buildconf
  25. buildconf.bat
  26. configure.ac
  27. curl-config.in
  28. docs/
  29. include/
  30. lib/
  31. libcurl.pc.in
  32. m4/
  33. maketgz
  34. packages/
  35. projects/
  36. scripts/
  37. src/
  38. tests/
  39. winbuild/
README.md

curl logo

CII Best Practices Coverity passed Travis-CI Build Status AppVeyor Build Status Cirrus Build Status Coverage Status Backers on Open Collective Sponsors on Open Collective Language Grade: C/C++ Codacy Badge

Curl is a command-line tool for transferring data specified with URL syntax. Find out how to use curl by reading the curl.1 man page or the MANUAL document. Find out how to install Curl by reading the INSTALL document.

libcurl is the library curl is using to do its job. It is readily available to be used by your software. Read the libcurl.3 man page to learn how!

You find answers to the most frequent questions we get in the FAQ document.

Study the COPYING file for distribution terms and similar. If you distribute curl binaries or other binaries that involve libcurl, you might enjoy the LICENSE-MIXING document.

Contact

If you have problems, questions, ideas or suggestions, please contact us by posting to a suitable mailing list.

All contributors to the project are listed in the THANKS document.

Website

Visit the curl web site for the latest news and downloads.

Git

To download the very latest source from the Git server do this:

git clone https://github.com/curl/curl.git

(you'll get a directory named curl created, filled with the source code)

Security problems

Report suspected security problems via our HackerOne page and not in public!

Notice

Curl contains pieces of source code that is Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan. This notice is included here to comply with the distribution terms.

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]