-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: dont crash on invalid brotli payload
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict' | ||
|
||
const { createServer } = require('node:http') | ||
const { tspl } = require('@matteo.collina/tspl') | ||
const { describe, test, after } = require('node:test') | ||
const { fetch } = require('..') | ||
const { once } = require('node:events') | ||
|
||
describe('https://github.com/nodejs/undici/issues/3616', () => { | ||
const cases = [ | ||
'x-gzip', | ||
'gzip', | ||
'deflate', | ||
'br' | ||
] | ||
|
||
for (const encoding of cases) { | ||
test(encoding, async t => { | ||
t = tspl(t, { plan: 2 }) | ||
const server = createServer((req, res) => { | ||
res.writeHead(200, { | ||
'Content-Length': '0', | ||
Connection: 'close', | ||
'Content-Encoding': encoding | ||
}) | ||
res.end() | ||
}) | ||
|
||
after(() => { | ||
server.close() | ||
}) | ||
|
||
server.listen(0) | ||
|
||
await once(server, 'listening') | ||
const result = await fetch(`http://localhost:${server.address().port}/`) | ||
|
||
t.ok(result.body.getReader()) | ||
|
||
process.on('uncaughtException', (reason) => { | ||
t.fail('Uncaught Exception:', reason, encoding) | ||
}) | ||
|
||
await new Promise(resolve => setTimeout(resolve, 100)) | ||
t.ok(true) | ||
}) | ||
} | ||
}) |