demo generated with vhs
rq
is an interactive HTTP client that parses and execute requests. It attempts to provide a minimal CLI
alternative to vscode-restclient.
rq
follows the standard RFC 2616.
Original author blogpost: https://protiumx.github.io/blog/posts/an-http-request-parser-with-rust-and-pest-rs/
cargo install --path rq-cli
The pest
grammar can be found here.
You can use the pest editor to try it out and check how it works.
-- request --
{request_line}\n
{header\n\n}*
{body\n}?
A request
is conformed by: { request_line, headers, body}
, where headers
and body
are optional
matches.
request_line
is conformed by:{ method, target, version }
.method
is one ofGET
,POST
,PUT
,DELETE
(optional, defaults toGET
).target
is the target url.version
is one ofHTTP/0.9
,HTTP/1.0
,HTTP/1.1
,HTTP/2.0
,HTTP/3.0
(optional, defaults toHTTP/1.1
)
headers
is a collection ofheader
{ header_name, header_value }
(optional).body
is anything that doesn't match headers and has a preceding line break, as specified in the RFC (optional).