curl / Mailing Lists / curl-users / Single Mail

curl-users

Re: Cannot get location header or follow location

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 26 Jul 2018 17:21:48 +0200 (CEST)

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.

-- 
  / daniel.haxx.se
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2018-07-26