9 个版本
0.0.7 | 2021 年 5 月 18 日 |
---|---|
0.0.5 | 2021 年 2 月 15 日 |
0.0.3 | 2020 年 12 月 18 日 |
0.0.2 | 2020 年 10 月 26 日 |
#481 in HTTP 客户端
37 每月下载
33KB
149 行
Longboard:轻松冲浪的 方法
$ longboard get https://async.rs
安装
$ cargo install longboard
使用方法
longboard 0.0.2
the easy way to surf
USAGE:
longboard [OPTIONS] <method> <url>
FLAGS:
--help
Prints help information
-V, --version
Prints version information
OPTIONS:
-b, --body <body>
provide a request body on the command line
example:
longboard post http://httpbin.org/post -b '{"hello": "world"}'
-c, --client <client>
http backend for surf. options: h1, curl, hyper
caveat: h1 currently does not support chunked request bodies,
so do not use that backend yet if you need to stream bodies [default: h1]
-f, --file <file>
provide a file system path to a file to use as the request body
alternatively, you can use an operating system pipe to pass a file in
three equivalent examples:
longboard post http://httpbin.org/anything -f ./body.json
longboard post http://httpbin.org/anything < ./body.json
cat ./body.json | longboard post http://httpbin.org/anything
-h, --headers <headers>...
provide headers in the form -h KEY1=VALUE1 KEY2=VALUE2
example:
longboard get http://httpbin.org/headers -h Accept=application/json Authorization="Basic u:p"
-j, --jar <jar>
a filesystem path to a cookie jar in ndjson format
note: this currently only persists "persistent cookies," which
either have a max-age or expires.
if the file does not yet exist, it will be created
example:
longboard get "https://httpbin.org/response-headers?Set-Cookie=USER_ID=10;+Max-Age=100" -j ~/.longboard.ndjson
ARGS:
<method>
<url>
尝试示例
$ longboard get http://httpin.org/get
$ longboard get https://httpbin.org/headers -h Some-Header="header value" User-Agent=longboard
$ longboard post https://httpbin.org/post -b "this is a request body"
$ longboard post http://httpbin.org/anything -b "a=b&c=d" -h content-type=application/x-www-form-urlencoded
$ longboard put https://httpbin.org/put -f ./Cargo.toml -h content-type=application/toml
$ longboard patch https://httpbin.org/patch < ./some-file
$ cat /dev/random | head -c1000 | base64 | longboard post https://httpbin.org/anything
$ longboard get https://httpbin.org/stream | cat
使此工具有用的 TODO
- 请求体
- 从文件系统
- 作为 CLI 参数
- 从 stdin(管道)
- 请求头
- 更多表情符号,自定义格式化程序
- 选择显示请求和响应的不同部分
- HTTP 状态 -> 退出代码
一些未来的想法
- 会话/存储的 cookie
- 交互式 repl 模式,方便使用同一客户端进行连续请求
- SSE 模式,可美观地打印 SSE 消息
- 将图像渲染为 ascii 以娱乐吗?
安全性
此包使用 #![forbid(unsafe_code)]
确保所有内容都在 100% 安全的 Rust 中实现。
许可
根据您的选择,受Apache 许可证 2.0 版本或MIT 许可证许可。除非您明确说明,否则您有意提交的任何贡献,根据 Apache-2.0 许可证的定义,都应如上所述双许可,无需任何附加条款或条件。
依赖关系
~42–63MB
~1M SLoC