You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/README.md
+11-37Lines changed: 11 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1425,10 +1425,8 @@ HTTPie does several things by default in order to make its terminal output easy
1425
1425
1426
1426
### Colors and formatting
1427
1427
1428
-
<!-- TODO: mention body colors/formatting are based on content-type + --response-mime (heuristics for JSON content-type) -->
1429
-
1430
1428
Syntax highlighting is applied to HTTP headers and bodies (where it makes sense).
1431
-
You can choose your preferred color scheme via the `--style` option if you don’t like the default one.
1429
+
You can choose your preferred color scheme via the --style option if you don’t like the default one.
1432
1430
There are dozens of styles available, here are just a few notable ones:
1433
1431
1434
1432
| Style | Description |
@@ -1448,6 +1446,12 @@ Use one of these options to control output processing:
1448
1446
|`--pretty=format`| Apply formatting |
1449
1447
|`--pretty=none`| Disables output processing. Default for redirected output |
1450
1448
1449
+
HTTPie looks at `Content-Type` to selectthe 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 typefor a response with `--response-mime`:
1450
+
1451
+
```bash
1452
+
$ http --response-mime=text/yaml pie.dev/get
1453
+
```
1454
+
1451
1455
Formatting has the following effects:
1452
1456
1453
1457
- HTTP headers are sorted by name.
@@ -1484,29 +1488,6 @@ sorting-related format options (currently it means JSON keys and headers):
1484
1488
1485
1489
This is something you will typically store as one of the default options in your [config](#config) file.
1486
1490
1487
-
### Response `Content-Type`
1488
-
1489
-
The `--response-as=value` option allows you to override the response `Content-Type` sent by the server.
1490
-
That makes it possible for HTTPie to print the response even when the server specifies the type incorrectly.
1491
-
1492
-
For example, the following request will force the response to be treated as XML:
1493
-
1494
-
```bash
1495
-
$ http --response-as=application/xml pie.dev/get
1496
-
```
1497
-
1498
-
And the following requests will force the response to use the [big5](https://docs.python.org/3/library/codecs.html#standard-encodings) encoding:
HTTPie tries to do its best to decode message bodies when printing them to the terminal correctly. It uses the encoding specified in the `Content-Type``charset` attribute. If a message doesn’t define its charset, we auto-detect it. For very short messages (1–32B), where auto-detection would be unreliable, we default to UTF-8. For cases when the response encoding is still incorrect, you can manually overwrite the response charset with `--response-charset`:
0 commit comments