Consider supporting reading http request from a file
See https://github.com/httpie/cli/issues/537#issuecomment-264718507
This helps with editing complex requests in an editor and allows them to be easily reused (similar to how collections are used in other tools).
Example:
Generate and save a request using --offline:
$ xhs jsonplaceholder.typicode.com/posts title=foo body=bar userId:=1 --offline > add-todo.http
Modify the request file (e.g remove some headers and add templated Authorization header):
POST /posts HTTP/1.1
Accept: application/json, */*;q=0.5
Authorization: Bearer {{ ACCESS_TOKEN }}
Content-Type: application/json
Host: jsonplaceholder.typicode.com
{
"title": "foo",
"body": "bar",
"userId": 1
}
Replay the request later using --http-file:
$ ACCESS_TOKEN=super-secret-token xhs --body --http-file add-todo.http
{
"title": "foo",
"body": "bar",
"userId": 1,
"id": 101
}
Edit: Actually, there is no need for templating if users can override request from cli e.g
$ xhs --body --http-file=add-todo.http 'authorization:Bearer super-secret-token'
{
"title": "foo",
"body": "bar",
"userId": 1,
"id": 101
}
cURL has https://github.com/curl/h2c for converting HTTP requests to a curl command
This plugin is very useful for VS Code users. xh is also supported.
https://github.com/wk-j/vscode-httpie