Buy commercial curl support from WolfSSL. We help you work
out your issues, debug your libcurl applications, use the API, port to new
platforms, add new features and more. With a team lead by the curl founder
himself.
Re: curl follow location method
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: jicea via curl-users <curl-users_at_lists.haxx.se>
Date: Tue, 11 Jul 2023 08:11:01 +0000
Thank you very much for your quick answer Daniel and your links.
Now (in my test case, I try to POST an empty body):
> curl --data '' --location 'http://localhost:8000/follow-redirect'
Works perfectly : I see a POST then a GET.
> curl --request POST --data '' --location 'http://localhost:8000/follow-redirect'
As designed, I can see the warning message "Note: Unnecessary use of -X or --request, POST is already inferred."
I see a POST then a POST, as designed once again.
I genuinely thought that the "--request" was unnecessary but it also has impact of --location (as mentioned in the docs btw)
It's clear now and I better understand the man message about -request "Normally you do not need this option. All sorts of GET, HEAD, POST and PUT requests are rather invoked by using dedicated command line options.".
I should use the dedicated method instead of --request.
I just have a final question, mainly theorical: if there is no dedicated option for a method (I think specifically of DELETE), the only option to use such a method is with -X/--request.
In that case, combining --request and --location, I won't be able "to test" a redirection with a GET method? The --request will force all subsequent request to use DELETE?
My question is rather theorical, I'm asking for any new feature!
Once again, thank you for your work, curl rocks!
Jc
On 10/07/2023 20:12, "Daniel Stenberg" <daniel_at_haxx.se <mailto:daniel_at_haxx.se>> wrote:
On Mon, 10 Jul 2023, jicea via curl-users wrote:
> For status code 301, 302 or 303, curl should switch to GET if I send a POST
> request with a "Location" header. I want to test it with a simple Flask
> endpoint, and I got this :
Let me first mention two blog posts of mine on related topics:
HTTP Redirects =>
https://daniel.haxx.se/blog/2016/02/18/http-redirects/ <https://daniel.haxx.se/blog/2016/02/18/http-redirects/>
Unnecessary use of curl -X =>
https://daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-curl-x/ <https://daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-curl-x/>
> $ curl --verbose --request POST --location 'http://localhost:8000/follow-redirect'
Now you can read that second blog post and ponder about your use of "--request
POST" in this command line! ;-)
--
/ daniel.haxx.se
| Commercial curl support up to 24x7 is available!
| Private help, bug fixes, support, ports, new features
| https://curl.se/support.html <https://curl.se/support.html>
____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.
This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.
Date: Tue, 11 Jul 2023 08:11:01 +0000
Thank you very much for your quick answer Daniel and your links.
Now (in my test case, I try to POST an empty body):
> curl --data '' --location 'http://localhost:8000/follow-redirect'
Works perfectly : I see a POST then a GET.
> curl --request POST --data '' --location 'http://localhost:8000/follow-redirect'
As designed, I can see the warning message "Note: Unnecessary use of -X or --request, POST is already inferred."
I see a POST then a POST, as designed once again.
I genuinely thought that the "--request" was unnecessary but it also has impact of --location (as mentioned in the docs btw)
It's clear now and I better understand the man message about -request "Normally you do not need this option. All sorts of GET, HEAD, POST and PUT requests are rather invoked by using dedicated command line options.".
I should use the dedicated method instead of --request.
I just have a final question, mainly theorical: if there is no dedicated option for a method (I think specifically of DELETE), the only option to use such a method is with -X/--request.
In that case, combining --request and --location, I won't be able "to test" a redirection with a GET method? The --request will force all subsequent request to use DELETE?
My question is rather theorical, I'm asking for any new feature!
Once again, thank you for your work, curl rocks!
Jc
On 10/07/2023 20:12, "Daniel Stenberg" <daniel_at_haxx.se <mailto:daniel_at_haxx.se>> wrote:
On Mon, 10 Jul 2023, jicea via curl-users wrote:
> For status code 301, 302 or 303, curl should switch to GET if I send a POST
> request with a "Location" header. I want to test it with a simple Flask
> endpoint, and I got this :
Let me first mention two blog posts of mine on related topics:
HTTP Redirects =>
https://daniel.haxx.se/blog/2016/02/18/http-redirects/ <https://daniel.haxx.se/blog/2016/02/18/http-redirects/>
Unnecessary use of curl -X =>
https://daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-curl-x/ <https://daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-curl-x/>
> $ curl --verbose --request POST --location 'http://localhost:8000/follow-redirect'
Now you can read that second blog post and ponder about your use of "--request
POST" in this command line! ;-)
--
/ daniel.haxx.se
| Commercial curl support up to 24x7 is available!
| Private help, bug fixes, support, ports, new features
| https://curl.se/support.html <https://curl.se/support.html>
____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.
This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.
-- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2023-07-11