Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(network-request): recognize zstd compression algorithm #15883

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
core(fix): recognize zstd as a compression algorithm
bug: #15882
  • Loading branch information
selfisekai committed Mar 24, 2024
commit 155f3dc0ac970650e40ad65b35530ecfac53c865
2 changes: 1 addition & 1 deletion core/lib/network-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ class NetworkRequest {
/^content-encoding$/i,
/^x-content-encoding-over-network$/i,
];
const compressionTypes = ['gzip', 'br', 'deflate'];
const compressionTypes = ['gzip', 'br', 'deflate', 'zstd'];
return record.responseHeaders.some(header =>
patterns.some(p => header.name.match(p)) && compressionTypes.includes(header.value)
);
Expand Down
18 changes: 18 additions & 0 deletions core/test/lib/network-request-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,22 @@ describe('NetworkRequest', () => {
})).toBe(false);
});
});

describe('#isContentEncoded', () => {
const isContentEncoded = NetworkRequest.isContentEncoded;

it('correctly identifies no compression', () => {
expect(isContentEncoded({responseHeaders: {}})).toBe(false);
});
it('correctly identifies brotli', () => {
expect(isContentEncoded({
responseHeaders: [{name: 'content-encoding', value: 'br'}],
})).toBe(true);
});
it('correctly identifies zstd', () => {
expect(isContentEncoded({
responseHeaders: [{name: 'content-encoding', value: 'zstd'}],
})).toBe(true);
});
});
});
Loading