undici: request dont decompress response body
Bug Description
Why doesn’t request support response body decompression?
import { request } from "undici";
const resp = await request('https://jsonplaceholder.typicode.com/todos/1', {
headers: {
'accept-encoding': 'gzip'
}
});
const content = await resp.body.text();
console.log(`status:`, resp.statusCode);
console.log(`encoding:`, resp.headers['content-encoding']);
console.log(`body:`, content); // compressed
Logs & Screenshots
using fetch
using request
Environment
undici@5.24.0
About this issue
- Original URL
- State: open
- Created 10 months ago
- Reactions: 1
- Comments: 15 (10 by maintainers)
See
RetryHandler
to get a sense of how an interceptor looks like.Hello ! Maybe something automatic, like if the response contains gzip encoding header we should decompress it ?