Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jcamiel opened this issue May 17, 2024 · 0 comments
Open

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

jcamiel opened this issue May 17, 2024 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@jcamiel
Copy link
Collaborator

jcamiel commented May 17, 2024

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'
@jcamiel jcamiel added the bug Something isn't working label May 17, 2024
@jcamiel jcamiel added this to the 5.0.0 milestone Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant