News for hackers. Stuff that matters.
Re:Hoppscotch: Open-source alternative to Postman by dsego on Monday February 28, 2022 @08:55AM (#30499810)
Is there a command line tool or editor plugin where I don't have to specify parameters, learn all the options. Instead I would just point it to an "http file" with http syntax and it "runs" it. Meaning the file contents are the http request that I want to send, eg

    GET / HTTP/1.1
    Cookie:
    Accept: text/html,...
    Host: news.ycombinator.com
    Accept-Language: en-GB,en;q=0.9
    Accept-Encoding: gzip, deflate, br
    Connection: keep-alive
And the I can just run it like so `http myRequest.http` There are some decade old sublime text plugins that claim to do this, but none of them seem to work anymore, from what I'm seeing.
Re:Hoppscotch: Open-source alternative to Postman by matt_heimer on Monday February 28, 2022 @10:00AM (#30500509)
From a CLI you run into issues with `nc` and the like supporting https. You can get close with `curl` since it has a -H option that allows you to provide headers in a file.

    curl -v -H @request1.txt neverssl.com
With a request1.txt header file

    X-Header: mine
    User-Agent: bob
Will generate a request of

    > GET / HTTP/1.1
    > Host: neverssl.com
    > Accept: */*
    > X-Header: mine
    > User-Agent: bob
You end up needing to know 3 options. -X <METHOD> to specify the HTTP method, -d @<file> if you want to send a request body, and -H.
Re:Hoppscotch: Open-source alternative to Postman by cbcoutinho on Monday February 28, 2022 @08:58AM (#30499832)
Re:Hoppscotch: Open-source alternative to Postman by andiareso on Monday February 28, 2022 @01:08PM (#30502946)
Second this one :D
Re:Hoppscotch: Open-source alternative to Postman by Extropy_ on Monday February 28, 2022 @09:00AM (#30499848)
I know IntelliJ IDEA Ultimate does that, not sure about any CLI tools. But it does look like you could use netcat to do that, for example:

cat myRequest.http | netcat example.com 80

Re:Hoppscotch: Open-source alternative to Postman by iib on Monday February 28, 2022 @09:05AM (#30499895)
Emacs can do this [1]. AFAIK, this is what inspired the vscode extension.

[1] https://github.com/pashky/restclient.el

Re:Hoppscotch: Open-source alternative to Postman by mnembrini on Monday February 28, 2022 @11:03AM (#30501374)
Re:Hoppscotch: Open-source alternative to Postman by kbd on Monday February 28, 2022 @12:26PM (#30502398)
Very cool, hadn't heard about that tool. Do you think that's more powerful than simple shell scripts around HTTPie/xh/curlie?
Re:Hoppscotch: Open-source alternative to Postman by theK on Monday February 28, 2022 @11:47PM (#30509718)
Certainly worth a try but one might start wondering whether this is so much better than classical bash + curl
Re:Hoppscotch: Open-source alternative to Postman by eriol on Monday February 28, 2022 @10:08AM (#30500595)
You may want to look at hurl: https://hurl.dev/
Re:Hoppscotch: Open-source alternative to Postman by SixDouble5321 on Tuesday March 01, 2022 @03:44AM (#30511341)
Httpie is what I use for this. I use shell scripts, with httpie commands which look very much like http syntax.

https://github.com/httpie/httpie

Re:Hoppscotch: Open-source alternative to Postman by smusamashah on Monday February 28, 2022 @12:38PM (#30502559)
Re:Hoppscotch: Open-source alternative to Postman by sharat87 on Monday February 28, 2022 @09:21PM (#30508462)
Hey! Author here. Thanks for sharing. Happy to answer any questions about this here. :)
Re:Hoppscotch: Open-source alternative to Postman by seanw444 on Monday February 28, 2022 @09:04AM (#30499888)
Emacs has a handy plugin for exactly that.

https://github.com/pashky/restclient.el

Re:Hoppscotch: Open-source alternative to Postman by User23 on Monday February 28, 2022 @04:30PM (#30505396)
There are also good options for GraphQL. I particularly like embedding the calls in org mode[1]. There's similar functionality for REST[2].

[1] https://github.com/jdormit/ob-graphql

[2] https://github.com/alf/ob-restclient.el

Re:Hoppscotch: Open-source alternative to Postman by WaxProlix on Monday February 28, 2022 @09:12AM (#30499968)
Can't `nc` (netcat) do (basically) this? `cat myRequest.http | nc <hostname> <port>`

Not robust, but it comes with all systems for free.

Re:Hoppscotch: Open-source alternative to Postman by mkdirp on Monday February 28, 2022 @10:06AM (#30500580)
Now do HTTPS.
Re:Hoppscotch: Open-source alternative to Postman by Kwpolska on Monday February 28, 2022 @11:11AM (#30501459)
Re:Hoppscotch: Open-source alternative to Postman by hultner on Monday February 28, 2022 @01:16PM (#30503035)
Yeah, nc 80. Or openssl s_client for https, you can also run through stunnel.