You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2025-11-27 22:38:54 +02:00
Add --response=mime and --response=charset docs (#1179)
* Add the "display encoding" section in the docs * Remove repetition * `--response=mime` / `--response=charset` docs * Cleanup * Cleanup * Cleanup Co-authored-by: Jakub Roztocil <jakub@roztocil.co>
This commit is contained in:
committed by
GitHub
parent
19691bba68
commit
a15fd6f966
@@ -1425,10 +1425,8 @@ HTTPie does several things by default in order to make its terminal output easy
|
||||
|
||||
HTTPie looks at `Content-Type` to select the right syntax highlighter and formatter for each message body. If that fails (e.g., the server provides the wrong type), or you prefer a different treatment, you can manually overwrite the mime type for a response with `--response-mime`:
|
||||
|
||||
Formatting has the following effects:
|
||||
|
||||
```bash
|
||||
- JSON data is indented, sorted by keys, and unicode escapes are converted
|
||||
$ http --response-mime=text/yaml pie.dev/get
|
||||
```
|
||||
|
||||
Formatting has the following effects:
|
||||
@@ -1448,6 +1446,12 @@ Use one of these options to control output processing:
|
||||
| Option | Default value | Shortcuts |
|
||||
| ---------------: | :-----------: | ------------------------ |
|
||||
| `headers.sort` | `true` | `--sorted`, `--unsorted` |
|
||||
| `json.format` | `true` | N/A |
|
||||
| `json.indent` | `4` | N/A |
|
||||
| `json.sort_keys` | `true` | `--sorted`, `--unsorted` |
|
||||
| `xml.format` | `true` | N/A |
|
||||
| `xml.indent` | `2` | N/A |
|
||||
|
||||
For example, this is how you would disable the default header and JSON key
|
||||
sorting, and specify a custom JSON indent size:
|
||||
|
||||
@@ -1484,29 +1488,6 @@ sorting-related format options (currently it means JSON keys and headers):
|
||||
```bash
|
||||
$ http octodex.github.com/images/original.jpg | convert - -resize 25% - | http example.org/Octocats
|
||||
```
|
||||
### Redirected output
|
||||
|
||||
HTTPie uses a different set of defaults for redirected output than for [terminal output](#terminal-output).
|
||||
The differences being:
|
||||
|
||||
- Formatting and colors aren’t applied (unless `--pretty` is specified).
|
||||
- Only the response body is printed (unless one of the [output options](#output-options) is set).
|
||||
- Also, binary data isn’t suppressed.
|
||||
|
||||
The reason is to make piping HTTPie’s output to another programs and downloading files work with no extra flags.
|
||||
Most of the time, only the raw response body is of an interest when the output is redirected.
|
||||
|
||||
Download a file:
|
||||
|
||||
```bash
|
||||
$ http pie.dev/image/png > image.png
|
||||
```
|
||||
|
||||
Download an image of an [Octocat](https://octodex.github.com/images/original.jpg), resize it using [ImageMagick](https://imagemagick.org/), and upload it elsewhere:
|
||||
|
||||
```bash
|
||||
$ http octodex.github.com/images/original.jpg | convert - -resize 25% - | http example.org/Octocats
|
||||
```
|
||||
|
||||
Force colorizing and formatting, and show both the request and the response in `less` pager:
|
||||
|
||||
@@ -1569,20 +1550,13 @@ Content-Type: application/octet-stream
|
||||
|
||||
Downloading 251.30 kB to "httpie-master.tar.gz"
|
||||
Done. 251.30 kB in 2.73862s (91.76 kB/s)
|
||||
HTTP/1.1 200 OK
|
||||
```
|
||||
|
||||
Content-Type: application/x-gzip
|
||||
|
||||
### Downloaded filename
|
||||
|
||||
Done. 251.30 kB in 2.73862s (91.76 kB/s)
|
||||
```
|
||||
|
||||
### Downloaded filename
|
||||
|
||||
There are three mutually exclusive ways through which HTTPie determines
|
||||
the output filename (with decreasing priority):
|
||||
|
||||
There are three mutually exclusive ways through which HTTPie determines
|
||||
the output filename (with decreasing priority):
|
||||
|
||||
1. You can explicitly provide it via `--output, -o`. The file gets overwritten if it already exists (or appended to with `--continue, -c`).
|
||||
2. The server may specify the filename in the optional `Content-Disposition` response header. Any leading dots are stripped from a server-provided filename.
|
||||
3. The last resort HTTPie uses is to generate the filename from a combination of the request URL and the response `Content-Type`. The initial URL is always used as the basis for the generated filename — even if there has been one or more redirects.
|
||||
|
||||
Reference in New Issue
Block a user