curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder Daniel himself.

Re: Not always using CURLOPT_CUSTOMREQUEST on redirects

From: Daniel Stenberg via curl-library <curl-library_at_lists.haxx.se>
Date: Thu, 27 Feb 2025 14:57:02 +0100 (CET)

On Tue, 25 Feb 2025, Daniel Stenberg via curl-library wrote:

> I propose [1] we add a way to change this: by adding a second bit for
> CURLOPT_FOLLOWLOCATION called CURLFOLLOW_OBEYCODE. It instructs libcurl that
> the response code should be adhered rather than ignored when following
> redirects. When used and a 301/302/303 response code is received, libcurl
> *changes* the method in spite of the given custom method.

I worked on a bit more and actually now lean towards *two* new modes for
CURLOPT_FOLLOWLOCATION. That makes the set work like this:

ENABLE - like always: the set custo method is used for all requests.

OBEYCODE - changes the method (or not) for the sequent request depending on
the specific status code in the redirect. On a 307/308, the original method is
kept.

FIRSTONLY - changes the method uncondtionally after the first request. To
which then depends on the status code that was returned.

> [1] = https://github.com/curl/curl/pull/16473

-- 
  / daniel.haxx.se || https://rock-solid.curl.dev
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2025-02-27