#417·xh

Consider supporting reading http request from a file

Author: ducaaleCreated Apr 25, 2025Updated Aug 5, 2026

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:

bash
$ 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):

http
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:

bash
$ 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

bash
$ xhs --body --http-file=add-todo.http 'authorization:Bearer super-secret-token'
{
    "title": "foo",
    "body": "bar",
    "userId": 1,
    "id": 101
}