Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xdiff-live and xreq-live

Two command-line tools for repeatable HTTP requests:

  • xdiff-live sends two configured requests and displays their response diff.
  • xreq-live sends one configured request and prints its response.

Install

cargo install --path .

xdiff-live

Create a YAML configuration containing one or more named profiles:

---
rust:
  req1:
    method: GET
    url: https://staging.example.com/api/status
    headers:
      user-agent: xdiff-live
    params:
      verbose: true
  req2:
    method: GET
    url: https://production.example.com/api/status
    params:
      verbose: true
  res:
    skip_headers:
      - date
      - set-cookie
    skip_body:
      - request_id

Run the comparison:

xdiff-live run --profile rust --config xdiff.yml

skip_body currently removes top-level JSON object fields. skip_headers removes the selected response headers case-insensitively before comparison. Response headers are sorted so their wire order does not create false differences. The two configured requests are sent concurrently through the same HTTP client.

xreq-live

An xreq configuration contains named request profiles:

---
create-todo:
  method: POST
  url: https://example.com/todos
  headers:
    content-type: application/json
  body:
    title: hello
    completed: false
xreq-live run --profile create-todo --config xreq.yml

Both commands require --profile and --config for run.

Overrides

Pass --extra-params (-e) more than once to override a request:

xreq-live run -p create-todo -c xreq.yml \
  -e page=first \
  -e count:=10 \
  -e %authorization="Bearer token" \
  -e @title="updated title" \
  -e @completed:=true
  • key=value sets a query parameter as a string.
  • %key=value sets a request header as a string.
  • @key=value sets a body field as a string.
  • key:=JSON and @key:=JSON preserve JSON types such as numbers, booleans, arrays, and objects.

JSON bodies are used by default when a body is present. Set content-type to application/x-www-form-urlencoded or multipart/form-data to select another encoding. Multipart currently supports text fields; file parts are not yet supported.

Requests have a 10-second connection timeout, a 30-second overall timeout, and a maximum of 10 redirects. Response bodies are limited to 10 MiB.

xdiff-live run returns status 0 when responses match, 1 when they differ, and 2 when execution fails. xreq-live returns 0 on success and 2 on an execution or configuration error. Errors are written to stderr.

Interactive configuration

The parse subcommand accepts URLs interactively and prints generated YAML:

xdiff-live parse
xreq-live parse

About

HTTP request and diff tools

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages