longboard

Longboard: The easy way to surf

APACHE-2.0 License

Downloads
6.6K
Stars
19
Committers
2

Longboard: The easy way to surf

$ longboard get https://async.rs

Installation

$ cargo install longboard

Usage

longboard 0.0.x
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>

Examples to try:

$ 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 for this to be useful

  • request bodies
    • from filesystem
    • as a cli arg
    • from stdin (pipe)
  • request headers
  • more emoji, custom formatters
  • opt into / out of displaying different parts of request and response
  • http status -> exit code

Some future ideas:

  • sessions/stored cookie jars
  • interactive repl mode for an easy way to make consecutive requests with the same client
  • sse mode that pretty-prints sse messages
  • render images to ascii for fun?

Safety

This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% Safe Rust.

License