curl / Mailing Lists / curl-library / Single Mail

curl-library

"CURLFOLLOW_IGNORE_CUSTOM"

From: Daniel Stenberg via curl-library <curl-library_at_cool.haxx.se>
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: https://github.com/curl/curl/pull/3803

It is my attempt to fix the issue users get when they use
CURLOPT_CUSTOMREQUEST together with CURLOPT_FOLLOWLOCATION: that the set
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!

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2019-04-24