cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: A small nudge to fix a frequent -X misuse?

From: Isaac Boukris <iboukris_at_gmail.com>
Date: Sat, 29 Aug 2015 18:40:01 -0400

On Sat, Aug 29, 2015 at 6:08 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> Hey friends!
>
> I see lots and lots of curl suggestions and examples on the internet use -X
> where it isn't needed. Like -XGET for an ordinary URL or using -d data
> -XPOST and so on. Just superfluous uses of -X that annoy me (possibly
> slightly more than I can really motivate).
>
> I wanted to see if anyone has opinions about a patch similar to the attached
> one. It will cause a warning get output if a pointless -X is used, to help
> the user figure this out. I also took the change to warn for -XHEAD as that
> will most likely cause a hanging connection in most cases.
>
> Example outputs:
>
> $ curl -XPOST -dmoo localhost
> Warning: Superfluous use of -X. --request, POST is already inferred.
> [operation continues]
>
> $ curl -XGET localhost
> Warning: Superfluous use of -X. --request, GET is already inferred.
> [operation continues]
>
> $ curl -XHEAD -I localhost
> Warning: Superfluous use of -X. --request, HEAD is already inferred.
> [operation continues]
>
> $ curl -XHEAD localhost
> Warning: Setting custom HTTP method to HEAD may not work the way you want.
>
> Thoughts?

I'd rather see the warning only in verbose mode (-v, not sure what warnf does).
That's inorder not to break existing scripts etc.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-08-30