cURL / Mailing Lists / curl-users / Single Mail

curl-users

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

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 30 Aug 2015 18:36:25 +0200 (CEST)

On Sun, 30 Aug 2015, Alex Bligh wrote:

>> 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).
>
> Please do not do this or only do this in verbose mode.

The problem with doing this in verbose mode only is that these users don't
normally use verbose. If they had used verbose they also most probably
woudld've already seen that the method was already set to the one they set
with -X.

> It isn't as if the default is always GET.

I would say that it is always GET _by default_, but you don't always use the
default.

> The default changes according to other parameters (e.g. presence of -d).

The method is changed according to what you want to do, yes.

> Given that, if I'm documenting a JSON call in curl, I'll *always* specify
> -XGET or -X POST (or whatever), so it's clear,

Then you're one of the persons I want to change! =)

I don't think it is clear. I think it actually makes a disservice to the users
reading that. First, I think it misleads the user into believing he or she
needs to use -X when using curl to do these operaitons and secondly, it
misleads the user into believing that the -X method is actually what tells
curl how to act. Like they may then wrongly believe that curl would act
differently if you did -XPOST or -XGET, when in fact curl doesn't care about
what -X is set to, but it is the other option(s) that control how it behaves.

> Making this look like an error just makes it harder to document things using
> a curl command line as an example.

I happen to think it is a mild error to use -X to set the same method curl
would use anyway. Perhaps error is a too strong word, but I don't think it is
the proper way to use curl.

I'm still intersted in reading more opinions on the matter!

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