-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CURLOPT_FOLLOWLOCATION: add a CURLFOLLOW_NO_CUSTOMMETHOD bit #8130
Conversation
|
I read that and it looks like cacheable database search results. So then the resource (database) changes and it's invalidated? I wonder how it will work in practice. |
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_CUSTOMMETHOD 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_CUSTOMMETHOD 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_CUSTOMMETHOD string override the method, disregarding what the HTTP response code suggests. Test 1589 added to verify the functionality. Closes #8130
38a0c0a
to
760c140
Compare
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_CUSTOMMETHOD 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_CUSTOMMETHOD 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_CUSTOMMETHOD string override the method, disregarding what the HTTP response code suggests. Test 1589 added to verify the functionality. Closes #8130
760c140
to
ffc9398
Compare
\fIenable\fP is a bitmask. If you set the \fICURLFOLLOW_NO_CUSTOMMETHOD\fP | ||
bit, it will tell libcurl that the method set with | ||
\fICURLOPT_CUSTOMREQUEST(3)\fP will not be used after a redirect if the HTTP | ||
response says so. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than have the user set curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, CURLFOLLOW_NO_CUSTOMMETHOD | CURLFOLLOW_ENABLE);
, you could instead define CURLFOLLOW_NO_CUSTOMMETHOD as 3 and get rid of CURLFOLLOW_ENABLE. If you feel the bitfield really is the way to go then you should add CURLFOLLOW_DISABLE as well, and document them both.
I'm not sensing any particular interest from users for this so I'll close this again for this time and maybe bring it back at a later time. |
(This is a re-run. This change was already proposed for inclusion in 7.66.0 in #3803 but due to lack of interest I retracted it back then. Since this change would allow us to make a
-X
from curl that is "less bad", which also might be interesting when considering a coming QUERY method, I think/hope it might get some more interest this time around!?)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.