cURL / Mailing Lists / curl-users / Single Mail

curl-users

A small nudge to fix a frequent -X misuse?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 30 Aug 2015 00:08:11 +0200 (CEST)

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?

-- 
  / daniel.haxx.se


-------------------------------------------------------------------
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