curl-users
Re: A small nudge to fix a frequent -X misuse?
Date: Sun, 30 Aug 2015 20:26:58 +0200 (CEST)
On Sun, 30 Aug 2015, Alex Bligh wrote:
>> 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.
>
> Really? I'm feeling slightly sensitive about this as it took me a little
> while yesterday to work out why my otherwise working script failed when I
> added a '-d' component - I'd not explicitly set '-X GET' but relied on it
> being the default.
Again, GET is the default, but you changed that with -d. -d does a POST so it
changes the method to POST.
> I thought in such a circumstance (presence of -d), '-X GET' did explicitly
> change the HTTP action from POST to GET.
That command line also would not cause a warning from my patch.
It changed the request into a GET with a request-body. That's a highly unusual
request and exactly for which purpose -X was created. I think using -X for
something like that is exactly right.
> Removing '-X GET' breaks it, as it uses 'POST' instead of 'GET'.
Just ramdomly removing -X uses will of course cause some scripts to not work
anymore, namely those uses that don't use superfluous -Xs.
> However, anyone reading that example and an example without '-d' will have
> to understand how curl changes the HTTP action depending on presence of
> '-d'.
Yes. But as I said already, I believe that's the right thing to teach users.
Or make it one step more complicated: add -L to your command line and see how
using -X can really screw things up in the subsequent request...
I note your opinion on this, even if I disagree with it.
-- / 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.htmlReceived on 2015-08-30