forked from nodejs/undici
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: respect
--max-http-header-size
Node.js flag (nodejs#2234)
* feat: respect Node.js flag * add test * cleaner test * fix test * update docs * revert empty space * remove already default value * add * don't use `globalThis.fetch` to pass test in Node.js 16 * add test under `test/fetch` * fix lint * import from `undici-fetch` * use correct paths, use `request` for pure undici test * fix Node.js 14 test
- Loading branch information
1 parent
1fa9c6b
commit d2d2796
Showing
5 changed files
with
50 additions
and
3 deletions.
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
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,23 @@ | ||
'use strict' | ||
|
||
const { execSync } = require('node:child_process') | ||
const { test } = require('tap') | ||
|
||
const command = 'node -e "require(\'.\').request(\'https://httpbin.org/get\')"' | ||
|
||
test("respect Node.js' --max-http-header-size", async (t) => { | ||
t.throws( | ||
// TODO: Drop the `--unhandled-rejections=throw` once we drop Node.js 14 | ||
() => execSync(`${command} --max-http-header-size=1 --unhandled-rejections=throw`), | ||
/UND_ERR_HEADERS_OVERFLOW/, | ||
'max-http-header-size=1 should throw' | ||
) | ||
|
||
t.doesNotThrow( | ||
() => execSync(command), | ||
/UND_ERR_HEADERS_OVERFLOW/, | ||
'default max-http-header-size should not throw' | ||
) | ||
|
||
t.end() | ||
}) |
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,23 @@ | ||
'use strict' | ||
|
||
const { execSync } = require('node:child_process') | ||
const { test } = require('tap') | ||
|
||
const command = 'node -e "require(\'./undici-fetch.js\').fetch(\'https://httpbin.org/get\')"' | ||
|
||
test("respect Node.js' --max-http-header-size", async (t) => { | ||
t.throws( | ||
// TODO: Drop the `--unhandled-rejections=throw` once we drop Node.js 14 | ||
() => execSync(`${command} --max-http-header-size=1 --unhandled-rejections=throw`), | ||
/UND_ERR_HEADERS_OVERFLOW/, | ||
'max-http-header-size=1 should throw' | ||
) | ||
|
||
t.doesNotThrow( | ||
() => execSync(command), | ||
/UND_ERR_HEADERS_OVERFLOW/, | ||
'default max-http-header-size should not throw' | ||
) | ||
|
||
t.end() | ||
}) |
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