What’s new in HTTPie 2.6.0
Tags: httpie, api, testing, cli
Published: 2021-10-23 15:58:02

---
title: What’s new in HTTPie 2.6.0
published: true
description: Charset detection, display charset and mime overwrite, support for XSSI-prefixed JSON, and other improvements.
tags: httpie, api, testing, cli
cover_image: https://httpie.io/Images/Share/cli.png
canonical_url: https://httpie.io/blog/httpie-2.6.0
---

This version of [HTTPie](https://httpie.io/) introduces numerous improvements to data display and formatting.

## Body charset detection

If a message’s `Content-Type` header doesn’t specify `charset`, HTTPie now auto-detects it from the body content, and then uses this information to correctly display the text on the terminal.

```bash
# Preview a Big5-encoded request w/o charset in Content-Type:
echo  '維基大典維基大典維基大典維基大典' \
    | iconv -f utf8 -t big5 \
    | http --offline pie.dev Content-Type:text/plain
```

Prior to HTTPie 2.6.0:

```http
POST / HTTP/1.1
Content-Type: text/plain

����j�����j�����j�����j��
```

With 2.6.0:
```http
POST / HTTP/1.1
Content-Type: text/plain

維基大典維基大典維基大典維基大典
```

You can [learn more about displaying encoding](https://httpie.iohttps://httpie.io/docs#display-encoding) in the docs.

## Response charset overwrite

When the server includes an incorrect `charset` in `Content-Type`, you can now overwrite that value for display purposes.

For example, the following response incorrectly specifies `charset=utf-8`:

```bash
$ http -F https://git.io/JiOaA
```

```http
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8

����j��]Wikipedia�
```

We can now fix that with `--response-charset`:

```bash
$ http -F --response-charset=big5 https://git.io/JiOaA
```

```http
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8

維基大典（Wikipedia)
```
## Response MIME overwrite

HTTPie looks at `Content-Type` to select the right [syntax highlighter and formatter](https://httpie.io/docs#colors-and-formatting) for each message body. If that fails (e.g., the server provides the wrong type), or you prefer a different treatment, you can now manually overwrite the mime type for the response with `--response-mime`. For example, here we’re formatting and colorizing a JSON response as if it were YAML:

```bash
$ http --response-mime=text/yaml pie.dev/get
```

## XSSI prefixes no longer break JSON formatting

HTTPie can now handle extraneous data preceding a JSON body.
For example, when an API uses an XSSI prefix.

Prior to HTTPie 2.6.0:

```
for(;;){"status": -1, "error":"The resource requires authentication."}
```

With 2.6.0, we highlight the non-JSON prefix, and then correctly format and color the rest:

```json
for(;;)
{
    "error": "The resource requires authentication.",
    "status": -1
}
```

## Duplicate JSON keys are now preserved

JSON doesn’t disallow repeated keys. However, before HTTPie 2.6.0, we’d incorrectly show only the last occurrence as a result of formatting the JSON:

```bash
$ http --print=B --offline --raw='{"A": 1,"A":2}' pie.dev
```
Prior to HTTPie 2.6.0:
```json
{
    "A": 2
}
```

Starting with HTTPie 2.6.0, we preserve all keys as shown below:

```json
{
    "A": 1,
    "A": 2
}
```


## Other improvements

- Silence warnings through using `--quiet, -q` twice (e.g. `-qq`) ([#1175](https://github.com/httpie/httpie/issues/1175)).
- List installed plugin list to `--debug` output ([#1165](https://github.com/httpie/httpie/issues/1165)).

## Community contributions

We’d like to thank these amazing people for their contributions to this release: [Annette Wilson](https://github.com/annettejanewilson), [Dave](https://github.com/davecheney), [Fabio Peruzzo](https://github.com/peruzzof), [Miro Hrončok](https://github.com/hroncok), [Omer Akram](https://github.com/om26er), [Vincent van ’t Zand](https://github.com/vovtz), [dkreeft](https://github.com/dkreeft), [崔小二](https://github.com/rogerdehe), and [黄海](https://github.com/hh-in-zhuzhou).

---

Originally published on [HTTPie blog](https://httpie.io/blog/httpie-2.6.0).