4 ms·
Truly one of the best cli tools out there. The api is concise and flexible, the --help flag is easy to read. But most importantly, there's sane defaults. defau
by gitgud 7y ago
Truly one of the best cli tools out there. The api is concise and flexible, the --help flag is easy to read. But most importantly, there's sane defaults.
defaults to GET request
http google.com
when json body exists it becomes a POST request
http google.com user=65
- stephenr 7y agoI don't get how you think that second part is a "sane" default. "user=65" is not valid JSON, unless you consider it a single JSON string literal. HTTPie converts that into a JSON object. Curl will send the data literally as you send it - if you want to send JSON, give it JSON as the body. If you want to send a "Form POST" quest, give it an encoded query string as the body. If HTTPie detected that what you gave it was valid JSON, or whatever other media type, and used that to 'guess' the request Content-Type, that would be useful and smart. But HTTPie not only mangles input, it mangles it in a way that is completely non obvious. passing it "foo=bar" will send a JSON encoded object like `{"foo": "bar"}`. passing it "foo=bar&baz=boo" will still send a JSON encoded object like `{"foo": "bar"}`. So, it knows that ampersand is a field separator, but then promptly ignores all the content after it? So, no. I call bullshit on "sane defaults" when it mangles data, and silently drops data it's given.
- gorjusborg 7y agoI think it's hard not to like the HTTPie interface if you give it a bit of time. The design is brilliant.
- stephenr 7y agoI gave specific examples where it's unintuitive and your response is "The design is brilliant". Touché sir, your argument has won the day. /s
- nothrabannosir 7y agoCharitably, the emphasis could be put on “if you give it a bit of time.” Read that way, it’s not an argument for intuitive UX, just a comment about how the UX grows on you. It doesn’t contradict what you said. Should it? After all, this is a discussion forum where regular humans can share their experiences. Not debate club.
- stephenr 7y agoA design isn't "brilliant" just because "people got used to it, despite how shitty it is".
- dkersten 7y agoYou can send it raw JSON too. For example: echo '{"foo": "bar"}' | http :8000
- mike_hock 7y agoCompletely agree. Opaque magic to "guess what you want" from incomplete or plain wrong arguments isn't "sane defaults." It also doesn't make it easy to use, because eventually the magic will guess wrong and it will go from magically the right thing even though I passed garbage arguments to completely the wrong thing at the drop of a hat. An example of a "sane default" where curl falls short might be to enable redirects by default, because that is usually what the user wants (and correct client behavior).
- BoorishBears 7y ago> Opaque magic to "guess what you want" from incomplete or plain wrong arguments isn't "sane defaults." Please explain how a well-defined key-value convention is equitable to "incomplete" or "plain wrong" arguments. In what way is any of this opaque when it's fully documented and quite easy to follow?: https://github.com/jakubroztocil/httpie#id16 https://github.com/jakubroztocil/httpie#id16
- detaro 7y agoFairly sure I'd forget all the time that it thinks giving it a syntax that looks like form-encoded obviously means I want to send a JSON request.
- BoorishBears 7y agokey=value is a convention used in so many places that have nothing to do with form encoding Would Java developers see this and imagine you're passing values for a .properties file? If you've never seen the tool before, you also wouldn't know how it works at all. Once you hit help for the first time (you know, to actually learn how to use it), knowing it defaults to JSON is pretty much a base truth. It's entire value proposition seems to be stongly tied to JSON support (2nd highest feature in the pitch at the top). This is like saying you'd forget jq takes JSON strings...
- stephenr 7y ago
- gitgud 7y agoSane defaults means it is making 99% of cases that I'm using the tool easier, convention over configuration. In 99% of cases httpie can assume that I'm making a POST request or a GET request with json or query params. Very rarely will I need to add custom headers, or change the Content-Type. Yes I can explicitly define the JSON body, headers and method type every time. Or I can use a tool which uses ..... "sane defaults"