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.
fix: set window option properly (nodejs#2048)
* fix: set window option properly * Update lib/fetch/request.js Co-authored-by: Robert Nagy <[email protected]> * Update lib/fetch/request.js Co-authored-by: Robert Nagy <[email protected]> * add test --------- Co-authored-by: Robert Nagy <[email protected]>
- Loading branch information
Showing
2 changed files
with
21 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,20 @@ | ||
'use strict' | ||
|
||
const { fetch } = require('../..') | ||
const { createServer } = require('http') | ||
const { once } = require('events') | ||
const { test } = require('tap') | ||
|
||
test('Receiving a 407 status code w/ a window option present should reject', async (t) => { | ||
const server = createServer((req, res) => { | ||
res.statusCode = 407 | ||
res.end() | ||
}).listen(0) | ||
|
||
t.teardown(server.close.bind(server)) | ||
await once(server, 'listening') | ||
|
||
// if init.window exists, the spec tells us to set request.window to 'no-window', | ||
// which later causes the request to be rejected if the status code is 407 | ||
await t.rejects(fetch(`http://localhost:${server.address().port}`, { window: null })) | ||
}) |