1
0
mirror of https://github.com/httpie/cli.git synced 2025-12-26 00:31:53 +02:00

Fix encoding error with non-prettified encoded responses

Removed `--format-option response.as` an promote `--response-as`: using
the format option would be misleading as it is now also used by non-prettified
responses.
This commit is contained in:
Mickaël Schoentgen
2021-09-30 10:58:08 +02:00
parent 71adcd97d0
commit 0b5f4d6b1c
11 changed files with 72 additions and 118 deletions

View File

@@ -1214,15 +1214,14 @@ You can further control the applied formatting via the more granular [format opt
This is something you will typically store as one of the default options in your [config](#config) file.
### Response `Content-Type`
#### Response `Content-Type`
The `--response-as=value` option is a shortcut for `--format-options response.as:value`,
and it allows you to override the response `Content-Type` sent by the server.
That makes it possible for HTTPie to pretty-print the response even when the server specifies the type incorrectly.
For example, the following request will force the response to be treated as XML:
```bash
The `--response-as=value` option allows you to override the response `Content-Type` sent by the server.
That makes it possible for HTTPie to print the response even when the server specifies the type incorrectly.
For example, the following request will force the response to be treated as XML:
```bash
$ http --response-as=application/xml pie.dev/get
```
And the following requests will force the response to use the [big5](https://docs.python.org/3/library/codecs.html#standard-encodings) encoding:
@@ -1237,11 +1236,10 @@ sorting-related format options (currently it means JSON keys and headers):
Given the encoding is not sent by the server, HTTPie will auto-detect it.
### Binary data
Binary data is suppressed for terminal output, which makes it safe to perform requests to URLs that send back binary data.
Binary data is also suppressed in redirected but prettified output.
Binary data is suppressed for terminal output, which makes it safe to perform requests to URLs that send back binary data.
Binary data is also suppressed in redirected but prettified output.
The connection is closed as soon as we know that the response body is binary,
```bash