-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix issue 2898
- Loading branch information
Showing
5 changed files
with
40 additions
and
13 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
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,33 @@ | ||
'use strict' | ||
|
||
const assert = require('node:assert') | ||
const { once } = require('node:events') | ||
const { createServer } = require('node:http') | ||
const { test } = require('node:test') | ||
const { fetch } = require('../..') | ||
|
||
// https://github.com/nodejs/undici/issues/2898 | ||
test('421 requests with a body work as expected', async (t) => { | ||
const expected = 'This is a 421 Misdirected Request response.' | ||
|
||
const server = createServer((req, res) => { | ||
res.statusCode = 421 | ||
res.end(expected) | ||
}).listen(0) | ||
|
||
t.after(server.close.bind(server)) | ||
await once(server, 'listening') | ||
|
||
for (const body of [ | ||
'hello', | ||
new Uint8Array(Buffer.from('helloworld', 'utf-8')) | ||
]) { | ||
const response = await fetch(`http://localhost:${server.address().port}`, { | ||
method: 'POST', | ||
body | ||
}) | ||
|
||
assert.deepStrictEqual(response.status, 421) | ||
assert.deepStrictEqual(await response.text(), expected) | ||
} | ||
}) |
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