curl / Mailing Lists / curl-users / Single Mail


Re: Cannot get location header or follow location

From: Osipov, Michael <>
Date: Thu, 26 Jul 2018 18:05:02 +0200

Am 2018-07-26 um 17:21 schrieb Daniel Stenberg:
> On Wed, 25 Jul 2018, Osipov, Michael (GS IT PD LD PLM) wrote:
>> Im trying to use a REST service which returns with HTTP/1.1 201 along
>> with the Location of the new resource after a POST request.
>> Unfortunately, I cannnot write out (-w, redirect_url) the value, so
>> does not work --location to automatically download that resource:
> ...
>> Curl always assumes the Location header is for redirects (3xx) only
>> and not for 2xx operations.
>> Is there a reason to still have this resriction these days? Do you
>> need another switch to explicit opt out from this?
> The write out variable is also called "redirect_url" because it relates
> wo the URL "it would have redirected to" - so it is definately and
> clearly made for the redirect case and redirects are always 30X responses.
> Expanding it to also work for non-3xx cases where the Location: header
> is used is an intersting suggestion. It should probably need to use
> another name or something to differentiate from the existing implied
> meaning that it was a 3xx response.
> I can't say that it will land in my top prio list of things to work on,
> but I wouldn't object to a patch that made this funtionality come real.

That's sounds really fair. I'd look into it next month. Shouldn't be too
hard to implement.

Received on 2018-07-26