File tree Expand file tree Collapse file tree 2 files changed +4
-8
lines changed
Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -1677,9 +1677,9 @@ async function httpNetworkOrCacheFetch (
16771677 // requestCurrentURL(request).password = TODO
16781678
16791679 // In browsers, the user will be prompted to enter a username/password before the request
1680- // is re-sent. To prevent an infinite 401 loop, return a network error for now.
1680+ // is re-sent. To prevent an infinite 401 loop, return the response for now.
16811681 // https://github.com/nodejs/undici/pull/4756
1682- return makeNetworkError ( )
1682+ return response
16831683 }
16841684
16851685 // 4. Set response to the result of running HTTP-network-or-cache fetch given
Original file line number Diff line number Diff line change @@ -9,18 +9,14 @@ const assert = require('node:assert')
99const { closeServerAsPromise } = require ( '../utils/node-http' )
1010
1111test ( 'Receiving a 401 status code should not cause infinite retry loop' , async ( t ) => {
12- let requestCount = 0
13-
1412 const server = createServer ( { joinDuplicateHeaders : true } , ( req , res ) => {
15- requestCount ++
16- console . log ( { requestCount } )
1713 res . statusCode = 401
18- res . setHeader ( 'WWW-Authenticate' , 'Basic realm="test"' )
1914 res . end ( 'Unauthorized' )
2015 } ) . listen ( 0 )
2116
2217 t . after ( closeServerAsPromise ( server ) )
2318 await once ( server , 'listening' )
2419
25- await assert . rejects ( ( ) => fetch ( `http://localhost:${ server . address ( ) . port } ` ) )
20+ const response = await fetch ( `http://localhost:${ server . address ( ) . port } ` )
21+ assert . strictEqual ( response . status , 401 )
2622} )
You can’t perform that action at this time.
0 commit comments