cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl -X POST --location response 302 should do GET ?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 12 Feb 2016 16:49:25 +0100 (CET)

On Fri, 12 Feb 2016, Eric Favre wrote:

> When curl follows a redirect and the request is not a plain GET (for
> example POST or PUT), it will do the following request with a GET if
> the HTTP response was 301, 302, or 303.
>
> Which makes sense, since it's the behavior of most browsers (even though
> it's not what RFC1945 says).

It is however what RFC 2616 and RFC 7231 say a client "MAY" do, and they're
slightly newer than RFC 1945...

> However, this is not the behavior I observed on curl 7.43.0. To check,
> I made a mock server with 3 simple services:

...

> $ curl -v --location --request POST
> 'http://private-f4bcd-ccuv1mocks2.apiary-mock.com/post_me_this'

See, you're using "--request" there. It tells curl you want to use "POST" as
the method and so it does. Yes, even on the directed-to requests. You asked
for it and you got it.

This behavior is even documented in the -X/--request section of the man page:
https://curl.haxx.se/docs/manpage.html#-X

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html
Received on 2016-02-12