Repository navigation
Release 8.1.0 - #81
harshrathorr wants to merge 4 commits into
Conversation
|
|
||
| const compressedResponseEncodings: string = 'gzip, compress, deflate, br'; | ||
|
|
||
| const uncompressedResponseEncoding: string = 'identity'; |
There was a problem hiding this comment.
Removed. Nothing is added to the request when the option is disabled, so the identity constant is gone.
|
|
||
| const invalidToken: string = 'Invalid token'; | ||
|
|
||
| const compressedResponseEncodings: string = 'gzip, compress, deflate, br'; |
There was a problem hiding this comment.
Is compress, deflate necessary? Also let's remove br at least for now, given the recent events
There was a problem hiding this comment.
Done, the default is now Accept-Encoding: gzip
| private setAcceptEncodingIfNotSpecified(config: InternalAxiosRequestConfig): void { | ||
| config.headers.set( | ||
| 'Accept-Encoding', | ||
| this.requestCompressedResponses ? compressedResponseEncodings : uncompressedResponseEncoding, |
There was a problem hiding this comment.
Let's just not add any header if the compression is not needed
There was a problem hiding this comment.
Done. With requestCompressedResponses: false no header is added. Note that axios' Node adapter then sends its own default (gzip, compress, deflate, br) because it sets Accept-Encoding when it is missing, so false means 'leave it to axios', not 'disable compression
| }; | ||
| } | ||
|
|
||
| private setAcceptEncodingIfNotSpecified(config: InternalAxiosRequestConfig): void { |
There was a problem hiding this comment.
The 3 lines of code inside this function are used exactly 1 time. What's the benefit of creating this function?
|
|
||
| private setAcceptEncodingIfNotSpecified(config: InternalAxiosRequestConfig): void { | ||
| if (this.requestCompressedResponses) { | ||
| config.headers.set('Accept-Encoding', compressedResponseEncoding, false); |
There was a problem hiding this comment.
Parameter mutation. Let's avoid this
| const testToken = 'unit-test-token'; | ||
| const testCorrelationId = 'test-correlation-id'; | ||
| const url = 'https://api.example.com/data'; | ||
| const methods = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options'] as const; |
There was a problem hiding this comment.
do we need the as const here?
| this.clientExceptionStatusCodeMapOverride = options?.clientExceptionStatusCodeMapOverride; | ||
| this.client = options?.client ?? axios.create(); | ||
| this.whitelistedDomains = options?.whitelistedDomains; | ||
| this.requestCompressedResponses = options?.requestCompressedResponses ?? true; |
There was a problem hiding this comment.
The default behavior should be the same as in the current version - no explicit compression headers are sent. Otherwise this'll be a somewhat breaking change

Summary
Jira: PRC-13163.
HttpClientnow explicitly asks servers for compressed responses, which reduces transferred data and NAT gateway costs.Changes
HttpClientOptions.requestCompressedResponses(defaulttrue). The request interceptor setsAccept-Encoding: gzip, compress, deflate, br.requestCompressedResponses: falsesendsAccept-Encoding: identity.Accept-Encodingheader set on the request, or in the defaults of a provided axios instance, always takes precedence. It is only set when absent, so the instance defaults are not mutated.8.1.0(new option; first stable 8.x release, includes the 8.0.0-beta changes):package.json,CHANGELOG.md,README.md.Why existing services keep working
HttpClientand plainaxiossend identicalAccept-Encoding: gzip, compress, deflate, br, and brotli/gzip responses are decoded transparently.createHeadersWithResolvedToken, auth stripping, cache keys, or retries. Tests cover each.Verification
yarn lint,yarn build,yarn test(146 tests, on Node 22) pass.as/anyintroduced in source. No dependency changes.