curl / Mailing Lists / curl-library / Single Mail



From: Daniel Stenberg via curl-library <>
Date: Wed, 24 Apr 2019 15:13:57 +0200 (CEST)

Hello team!

I just want to draw your attention to a little PR I've filed that can use a
little of your thoughts:

It is my attempt to fix the issue users get when they use
custom method *overrides* the method curl would otherwise possibly use after
the redirect as the HTTP response code tells it.

This behavior has more than once bitten users and we've seen bugs reported on
this on several occasions.

Currently (before this PR), the solution to this problem has been to not use
this combination: either switch off CURLOPT_FOLLOWLOCATION and follow
redirects "manually" or to not use CURLOPT_CUSTOMREQUEST and rely on curl
doing the right thing by itself. Both being rather annoying "solutions" since
these users used these two options for a reason...

The PR introduces a new bit to set to the CURLOPT_FOLLOWLOCATION option
(currently called CURLFOLLOW_IGNORE_CUSTOM), that when set will make the
method set in CURLOPT_CUSTOMREQUEST only be used for the initial request and
then let the HTTP response code dictate what to do in the following request
(if there indeed was a redirect).

Even though I presume in most cases users actually already assumed curl would
do this, we can't really change the existing behavior as then we'll just risk
breaking other existing applications that now rely on it.

I've tried to introduce this in a manner that should work nicely both forwards
and backwards with older/newer libraries etc.

The name of the option (CURLFOLLOW_IGNORE_CUSTOM) is possibly not the best so
I could use help with the bike-shedding here.

Also, I've not yet written any code that offers this ability to the command
line tool but I think it will be appricated there too so we should come up
with a command line option name as well!

Received on 2019-04-24