Skip to content

Bad curl debug logs with POST request and --location #2797

Closed
@jcamiel

Description

@jcamiel

With this file (follow redirection from a POST request)

POST https://foo.com
[Options]
location: true
HTTP 200
[Asserts]
url == "https://bar.com"

Hurl 4.3.0 implements curl's behaviour:

From https://curl.se/docs/manpage.html#-L:

When curl follows a redirect and if the request is a POST, it sends the following request with a GET if the HTTP response was 301, 302, or 303. If the response code was any other 3xx code, curl resends the following request using the same unmodified method.

In Hurl debugs logs, the curl command is:

* Request can be run with the following curl command:
* curl --request POST --location 'https://foo.com'

This command will NOT make a POST request followed by a GET redirection

This command will force all methods to be POST and so does not corresponds to the behavior of Hurl file.

As https://curl.se/docs/manpage.html#-X, --location and --request/-X does not well play together:

The method string you set with -X, --request is used for all requests, which if you for example use -L, --location may cause unintended side-effects when curl does not change request method according to the HTTP 30x response codes - and similar.

In https://daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-curl-x/ the "right" curl command in this case should be:

* Request can be run with the following curl command:
* curl --data '' --location 'https://foo.com'

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions