TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Hurl: Run and test HTTP requests with plain text

237 pointsby delducaover 2 years ago

22 comments

gregwebsover 2 years ago
A better url might be <a href="https:&#x2F;&#x2F;hurl.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;hurl.dev&#x2F;</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.
评论 #33748268 未加载
评论 #33745483 未加载
评论 #33747611 未加载
smartmicover 2 years ago
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&#x2F;UX.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;pashky&#x2F;restclient.el" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pashky&#x2F;restclient.el</a>
评论 #33749624 未加载
benatkinover 2 years ago
I think maybe I would prefer HCL.<p>instead of:<p><pre><code> GET https:&#x2F;&#x2F;example.org&#x2F;data.tar.gz HTTP&#x2F;1.0 200 [Asserts] sha256 == hex,039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81; </code></pre> ...this?<p><pre><code> get &quot;https:&#x2F;&#x2F;example.org&#x2F;data.tar.gz&quot; { sha = &quot;039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81&quot; } </code></pre> Or, having a separate category for asserts:<p><pre><code> get &quot;https:&#x2F;&#x2F;example.org&#x2F;data.tar.gz&quot; { asserts { sha = &quot;039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81&quot; status = 200 } } </code></pre> Or KDL (<a href="https:&#x2F;&#x2F;github.com&#x2F;kdl-org&#x2F;kdl" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kdl-org&#x2F;kdl</a>):<p><pre><code> get &quot;https:&#x2F;&#x2F;example.org&#x2F;data.tar.gz&quot; { asserts { sha &quot;039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81&quot; status 200 } }</code></pre>
mstadeover 2 years ago
Not two days ago I had the thought that it&#x27;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&#x27;t wait to give it a spin.<p>Thank you so much for sharing!
评论 #33748857 未加载
评论 #33749567 未加载
dnsmichiover 2 years ago
Great tool and documentation &lt;3<p>Started investigating how it can be integrated into GitLab CI&#x2F;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:&#x2F;&#x2F;gitlab.com&#x2F;everyonecancontribute&#x2F;dev&#x2F;hurl-playground#simple-cicd" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;everyonecancontribute&#x2F;dev&#x2F;hurl-playground...</a><p>Efficient - build a custom container image (the upstream container image behaves unexpected when overriding the entrypoint for CI&#x2F;CD, need to investigate and create an issue) Example in <a href="https:&#x2F;&#x2F;gitlab.com&#x2F;everyonecancontribute&#x2F;dev&#x2F;hurl-playground#efficient-cicd" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;everyonecancontribute&#x2F;dev&#x2F;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:&#x2F;&#x2F;dnsmichi.at HTTP&#x2F;1.1 200 [Asserts] body contains &quot;Everything is a DNS problem&quot; $ hurl --test dnsmichi.at.hurl </code></pre> While reading the documentation and all its great ways to use assertions on response <a href="https:&#x2F;&#x2F;hurl.dev&#x2F;docs&#x2F;asserting-response.html" rel="nofollow">https:&#x2F;&#x2F;hurl.dev&#x2F;docs&#x2F;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:&#x2F;&#x2F;hn.algolia.com&#x2F;api&#x2F;v1&#x2F;search [QueryStringParams] query: gitlab tags: front_page HTTP&#x2F;2 200 [Asserts] jsonpath &quot;$.hits&quot; count &gt; 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:&#x2F;&#x2F;gitlab.com&#x2F;everyonecancontribute&#x2F;dev&#x2F;hurl-playground" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;everyonecancontribute&#x2F;dev&#x2F;hurl-playground</a>
andreineculauover 2 years ago
KATT <a href="https:&#x2F;&#x2F;github.com&#x2F;for-GET&#x2F;katt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;for-GET&#x2F;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:&#x2F;&#x2F;github.com&#x2F;for-GET&#x2F;katt&#x2F;blob&#x2F;master&#x2F;doc&#x2F;example-httpbin.apib" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;for-GET&#x2F;katt&#x2F;blob&#x2F;master&#x2F;doc&#x2F;example-http...</a><p>Disclaimer: I&#x27;m one of the authors, thus biased, but the reason I&#x27;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.
account-5over 2 years ago
When would you use this over just curl? Genuine question. I like plain text where I can use it, but don&#x27;t understand the benefit of this over curl.
评论 #33746279 未加载
javajoshover 2 years ago
You can get a worse version of this functionality out of IntelliJ&#x27;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:&#x2F;&#x2F;www.jetbrains.com&#x2F;help&#x2F;idea&#x2F;http-client-in-product-code-editor.html#using-response-handler-scripts" rel="nofollow">https:&#x2F;&#x2F;www.jetbrains.com&#x2F;help&#x2F;idea&#x2F;http-client-in-product-c...</a>
ushakovover 2 years ago
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&#x2F;CD<p><a href="https:&#x2F;&#x2F;github.com&#x2F;stepci&#x2F;stepci" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;stepci&#x2F;stepci</a><p>Disclaimer: I&#x27;m the original author
andrewfromxover 2 years ago
Written in rust, lets you define a series of http urls to hit and assert info about what&#x27;s returned. i.e. a count of items in a json array, or a string value of one specific json string.
dangover 2 years ago
Related:<p><i>Show HN: Hurl – Run and test HTTP requests with plain text, curl and Rust</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=28758226" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;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:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=27026178" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=27026178</a> - May 2021 (15 comments)<p><i>Show HN: Hurl – Run and test HTTP requests</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=25655737" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=25655737</a> - Jan 2021 (11 comments)<p><i>Make HTTP requests from your browser</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=3439653" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=3439653</a> - Jan 2012 (66 comments)<p><i>Hurl is back: <a href="http:&#x2F;&#x2F;hurl.it&#x2F;" rel="nofollow">http:&#x2F;&#x2F;hurl.it&#x2F;</a></i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=1881945" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=1881945</a> - Nov 2010 (2 comments)<p><i>Hurl</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=1311146" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=1311146</a> - May 2010 (31 comments)<p><i>Hurl</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=818648" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=818648</a> - Sept 2009 (31 comments)
评论 #33745924 未加载
totetsuover 2 years ago
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.
评论 #33749773 未加载
hankchinaskiover 2 years ago
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
guilhasover 2 years ago
Some how I did small test and liked httpyac better, for being able to import requests from other files<p><a href="https:&#x2F;&#x2F;httpyac.github.io" rel="nofollow">https:&#x2F;&#x2F;httpyac.github.io</a><p>Anyone compared both and have an opinion?
评论 #33753645 未加载
keithalewisover 2 years ago
Shout-out to Don Libes <a href="https:&#x2F;&#x2F;wiki.tcl-lang.org&#x2F;page&#x2F;Expect" rel="nofollow">https:&#x2F;&#x2F;wiki.tcl-lang.org&#x2F;page&#x2F;Expect</a>. See, e.g., <a href="https:&#x2F;&#x2F;www.99-bottles-of-beer.net&#x2F;language-expect-249.html" rel="nofollow">https:&#x2F;&#x2F;www.99-bottles-of-beer.net&#x2F;language-expect-249.html</a>
coredog64over 2 years ago
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.
theptipover 2 years ago
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:&#x2F;&#x2F;github.com&#x2F;karatelabs&#x2F;karate" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;karatelabs&#x2F;karate</a>
评论 #33748403 未加载
gbourneover 2 years ago
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?
评论 #33749114 未加载
ploppyploppyover 2 years ago
Love this tool. Was very useful at a previous place and its Rust APIs were easy to extend
评论 #33747958 未加载
ccakesover 2 years ago
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:&#x2F;&#x2F;github.com&#x2F;federicotdn&#x2F;verb" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;federicotdn&#x2F;verb</a>
ilytover 2 years ago
IntelliJ have that feature builtin IIRC
评论 #33745390 未加载
prhrbover 2 years ago
Very useful