micha / resty

Little command line REST client that you can use in pipelines (bash or zsh).
MIT License
2.65k stars 143 forks source link

GET needs -G to pass query string parameters #16

Closed eproxus closed 13 years ago

eproxus commented 13 years ago

The GET command currently needs -G to work with query string parameters. My understanding of curl is that if -d is used without -G curl switches to POST instead. Shouldn't resty always use -G with the GET command?

micha commented 13 years ago

RFC 2616 doesn't seem to be very specific about whether a message body can be included in a GET request or not. To me this means that you might want to send the data in the message body sometime. I agree that it would be better not needing the -G, defaulting to sending parameters in the query string, but it would be a complication to implement this.

Something that I have been meaning to take a look at is mixing query string and message body parameters in the same request. Currently you have to choose one or the other for each request. I'd like to be able to do like

POST /Blah '{foo: "bar"}' -d arg=val

to get

POST /Blah?arg=val HTTP/1.1
User-Agent: curl/7.18.2 (x86_64-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.8 libssh2/0.18
Host: localhost:9090
Accept: */*
Content-Length: 14
Content-Type: application/x-www-form-urlencoded

{foo:"bar"}
@-    
eproxus commented 13 years ago

Yeah, and curl doesn't really allow -G again to cancel a GET, or any flag that forces a POST.

micha commented 13 years ago

It would be possible to use another option, like -Q or something (I don't remember which letters are available--curl takes up most of the alphabet in options already), and then do some fancy footwork and insert -G only if -Q isn't specified, or something like that.

eproxus commented 13 years ago

I think it is okay to keep it as it is, since knowing curl will allow you to do whatever you want. Right now it gives you no surprises which is always nice. :-)