From a0a8dc565ed5fcbe21c8a8e4e07d6bb51b185c96 Mon Sep 17 00:00:00 2001 From: Nathan Date: Thu, 19 Dec 2024 22:02:19 -0300 Subject: [PATCH] fix: compressed option should be false by default (#567) The `compressed` option is not enabled by default. There is no code setting it to true, except where the old `gzip` property is true. I confirmed this behavior in testing. The documentation for it appears to have been inadvertently updated when the `timing` option was added in commit 1d26bb8. ## Summary by CodeRabbit - **Documentation** - Updated `README.md` to reflect the change in default value for the `compressed` option in the `async request(url[, options])` method from `true` to `false`. - **Bug Fixes** - Changed the default behavior of the `compressed` property in request handling to prevent automatic decoding of `gzip` and `br` responses unless specified by the user. - **Chores** - Deprecated the `ctx` property in `RequestOptions`, recommending the use of the `opaque` property instead. --- README.md | 2 +- src/Request.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 094ee3ef..bd29facc 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ console.log('status: %s, body size: %d, headers: %j', res.status, data.length, r - ***formatRedirectUrl*** Function - Format the redirect url by your self. Default is `url.resolve(from, to)`. - ***beforeRequest*** Function - Before request hook, you can change every thing here. - ***streaming*** Boolean - let you get the `res` object when request connected, default `false`. alias `customResponse` - - ***compressed*** Boolean - Accept `gzip, br` response content and auto decode it, default is `true`. + - ***compressed*** Boolean - Accept `gzip, br` response content and auto decode it, default is `false`. - ***timing*** Boolean - Enable timing or not, default is `true`. - ***socketPath*** String | null - request a unix socket service, default is `null`. - ***highWaterMark*** Number - default is `67108864`, 64 KiB. diff --git a/src/Request.ts b/src/Request.ts index bb776167..bcd81ea5 100644 --- a/src/Request.ts +++ b/src/Request.ts @@ -105,7 +105,7 @@ export type RequestOptions = { formatRedirectUrl?: (a: any, b: any) => void; /** Before request hook, you can change every thing here. */ beforeRequest?: (...args: any[]) => void; - /** Accept `gzip, br` response content and auto decode it, default is `true`. */ + /** Accept `gzip, br` response content and auto decode it, default is `false`. */ compressed?: boolean; /** * @deprecated