Skip to content

Commit 51e4c0c

Browse files
timfishlobsterkatie
authored andcommitted
fix(node): Compression headers leak between requests (#5203)
1 parent 1d95d09 commit 51e4c0c

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

packages/node/src/transports/http.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,18 @@ function createRequestExecutor(
105105
return new Promise((resolve, reject) => {
106106
let body = streamFromBody(request.body);
107107

108-
if (request.body.length > GZIP_THRESHOLD) {
109-
options.headers = {
110-
...options.headers,
111-
'content-encoding': 'gzip',
112-
};
108+
const headers: Record<string, string> = { ...options.headers };
113109

110+
if (request.body.length > GZIP_THRESHOLD) {
111+
headers['content-encoding'] = 'gzip';
114112
body = body.pipe(createGzip());
115113
}
116114

117115
const req = httpModule.request(
118116
{
119117
method: 'POST',
120118
agent,
121-
headers: options.headers,
119+
headers,
122120
hostname,
123121
path: `${pathname}${search}`,
124122
port,

packages/node/test/transports/http.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ function setupTestServer(
4242

4343
const stream = req.headers['content-encoding'] === 'gzip' ? req.pipe(createGunzip({})) : req;
4444

45-
stream.on('error', () => {});
46-
4745
stream.on('data', data => {
4846
chunks.push(data);
4947
});

0 commit comments

Comments
 (0)