A better url might be <a href="https://hurl.dev/" rel="nofollow">https://hurl.dev/</a><p>Hurl runs super fast without startup latency unlike a lot of tools in this category written in node. The plain text format can be checked in and this can be part of your CI process. Hurl can capture data from previous requests to run workflows and serve as a testing tool. The main downside is the lack of a GUI, although I imagine it being not that hard to do something like make a plugin for VSCode that will add a run button to the text file and display the result in the editor.
I recently switch from custom Bash wrappers around curl to restclient.el [1]. It has similar features. Especially nice is the integration with jq for fetching specific data (or inspection of results with jq-mode). And, whoever is inclined to appreciate it, the fact that I can stay within Emacs. No need to get familiar with a new UI/UX.<p>[1]: <a href="https://github.com/pashky/restclient.el" rel="nofollow">https://github.com/pashky/restclient.el</a>
I think maybe I would prefer HCL.<p>instead of:<p><pre><code> GET https://example.org/data.tar.gz
HTTP/1.0 200
[Asserts]
sha256 == hex,039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81;
</code></pre>
...this?<p><pre><code> get "https://example.org/data.tar.gz" {
sha = "039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81"
}
</code></pre>
Or, having a separate category for asserts:<p><pre><code> get "https://example.org/data.tar.gz" {
asserts {
sha = "039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81"
status = 200
}
}
</code></pre>
Or KDL (<a href="https://github.com/kdl-org/kdl" rel="nofollow">https://github.com/kdl-org/kdl</a>):<p><pre><code> get "https://example.org/data.tar.gz" {
asserts {
sha "039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81"
status 200
}
}</code></pre>
Not two days ago I had the thought that it'd be so nice if I could write tests that were just plain text HTTP requests, and that the assertions would be just be comparing the responses to stored plain text HTTP responses, kind of like how snapshot assertions works in the React world. From a cursory glance this looks even better than what I had in mind, can't wait to give it a spin.<p>Thank you so much for sharing!
Great tool and documentation <3<p>Started investigating how it can be integrated into GitLab CI/CD in the most efficient way.<p>Simple - install Hurl using before_script every time into the used container image. Example in <a href="https://gitlab.com/everyonecancontribute/dev/hurl-playground#simple-cicd" rel="nofollow">https://gitlab.com/everyonecancontribute/dev/hurl-playground...</a><p>Efficient - build a custom container image (the upstream container image behaves unexpected when overriding the entrypoint for CI/CD, need to investigate and create an issue) Example in <a href="https://gitlab.com/everyonecancontribute/dev/hurl-playground#efficient-cicd" rel="nofollow">https://gitlab.com/everyonecancontribute/dev/hurl-playground...</a><p>A quick example to check the website body can be achieved with<p><pre><code> $ vim dnsmichi.at.hurl
GET https://dnsmichi.at
HTTP/1.1 200
[Asserts]
body contains "Everything is a DNS problem"
$ hurl --test dnsmichi.at.hurl
</code></pre>
While reading the documentation and all its great ways to use assertions on response <a href="https://hurl.dev/docs/asserting-response.html" rel="nofollow">https://hurl.dev/docs/asserting-response.html</a> and play with regex, and even built-in JSON parsing, I thought of querying the Algolia search API for HN:<p><pre><code> $ vim hackernews.hurl
GET https://hn.algolia.com/api/v1/search
[QueryStringParams]
query: gitlab
tags: front_page
HTTP/2 200
[Asserts]
jsonpath "$.hits" count > 0
$ hurl --test hackernews.hurl
</code></pre>
Not perfect yet, but shows the possibilities and maybe kicks off more ideas.<p>Will add more use cases, upstream PRs, and a blog post soon. <a href="https://gitlab.com/everyonecancontribute/dev/hurl-playground" rel="nofollow">https://gitlab.com/everyonecancontribute/dev/hurl-playground</a>
KATT <a href="https://github.com/for-GET/katt" rel="nofollow">https://github.com/for-GET/katt</a> is the same concept, but following the pattern matching philosophy. Written in Erlang, available as a CLI tool as well but needs the erlang runtime installed.<p>Code example: <a href="https://github.com/for-GET/katt/blob/master/doc/example-httpbin.apib" rel="nofollow">https://github.com/for-GET/katt/blob/master/doc/example-http...</a><p>Disclaimer: I'm one of the authors, thus biased, but the reason I'm mentioning KATT is that the low barrier of entry for captures and asserts makes it a nice requirement tool for non-techs to write complex API scenarios.
When would you use this over just curl? Genuine question. I like plain text where I can use it, but don't understand the benefit of this over curl.
You can get a worse version of this functionality out of IntelliJ's http client[0]. Hurl seems better for several reasons, although I wish there was an example showing a few more useful tricks:<p>1 - When the content of a JSON variable is an XML string, or a JSON string, detect this and format white space for readability.<p>2 - Support pulling either the entire request or just the body from a file, and looping over all files in a directory.<p>3 - Pull data out of a response, put it in an environment used by later lines in the script.<p>0 - <a href="https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html#using-response-handler-scripts" rel="nofollow">https://www.jetbrains.com/help/idea/http-client-in-product-c...</a>
If you like hurl, you should also take a look at Step CI, which uses YAML, generates tests from your OpenAPI spec and integrates with CI/CD<p><a href="https://github.com/stepci/stepci" rel="nofollow">https://github.com/stepci/stepci</a><p>Disclaimer: I'm the original author
Written in rust, lets you define a series of http urls to hit and assert info about what's returned. i.e. a count of items in a json array, or a string value of one specific json string.
Related:<p><i>Show HN: Hurl – Run and test HTTP requests with plain text, curl and Rust</i> - <a href="https://news.ycombinator.com/item?id=28758226" rel="nofollow">https://news.ycombinator.com/item?id=28758226</a> - Oct 2021 (49 comments)<p>-------<p>Edit: these are apparently not the same thing (thanks to johns for pointing this out):<p><i>Show HN: Hurl.it is back – Make HTTP Requests</i> - <a href="https://news.ycombinator.com/item?id=27026178" rel="nofollow">https://news.ycombinator.com/item?id=27026178</a> - May 2021 (15 comments)<p><i>Show HN: Hurl – Run and test HTTP requests</i> - <a href="https://news.ycombinator.com/item?id=25655737" rel="nofollow">https://news.ycombinator.com/item?id=25655737</a> - Jan 2021 (11 comments)<p><i>Make HTTP requests from your browser</i> - <a href="https://news.ycombinator.com/item?id=3439653" rel="nofollow">https://news.ycombinator.com/item?id=3439653</a> - Jan 2012 (66 comments)<p><i>Hurl is back: <a href="http://hurl.it/" rel="nofollow">http://hurl.it/</a></i> - <a href="https://news.ycombinator.com/item?id=1881945" rel="nofollow">https://news.ycombinator.com/item?id=1881945</a> - Nov 2010 (2 comments)<p><i>Hurl</i> - <a href="https://news.ycombinator.com/item?id=1311146" rel="nofollow">https://news.ycombinator.com/item?id=1311146</a> - May 2010 (31 comments)<p><i>Hurl</i> - <a href="https://news.ycombinator.com/item?id=818648" rel="nofollow">https://news.ycombinator.com/item?id=818648</a> - Sept 2009 (31 comments)
My qualm with this app is for a Linux user you can already build a system like that to yourself by simply using telnet and typing the HTTP directly down the pipe. The bonus is that you get to memorize all the protocol messages that way too.
Nice tool. I’m just wary of learning custom syntax. Maybe could use the same primitive of existing unix tools and make the whole a lot more orthogonal and frictionless. Jq syntax for parsing json, awk for text
Some how I did small test and liked httpyac better, for being able to import requests from other files<p><a href="https://httpyac.github.io" rel="nofollow">https://httpyac.github.io</a><p>Anyone compared both and have an opinion?
Shout-out to Don Libes <a href="https://wiki.tcl-lang.org/page/Expect" rel="nofollow">https://wiki.tcl-lang.org/page/Expect</a>.
See, e.g., <a href="https://www.99-bottles-of-beer.net/language-expect-249.html" rel="nofollow">https://www.99-bottles-of-beer.net/language-expect-249.html</a>
Taking this further, it would be interesting to see this applied to cloud infra descriptions for deployment testing. Yes, you can write it in a programming language but it’s tedious and this same idea would be applicable: Get a resource ID then make some detailed describe calls to assert that it’s provisioned as expected.
I recently found a BDD style tool that has native HTTP comprehension, which seems like it hits a similar area in the testing concept space:<p><a href="https://github.com/karatelabs/karate" rel="nofollow">https://github.com/karatelabs/karate</a>
Really impressed. The ability to chain the http calls with assertions is great. The one thing I would prefer is to set the environment variables also in the .hurl file rather than in a .env file. Also, how do you access the key of a nested object?
Not as usable for testing, but verb.el[1] is a great tool for doing something very similar in org-mode<p>[1] <a href="https://github.com/federicotdn/verb" rel="nofollow">https://github.com/federicotdn/verb</a>