File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -1048,7 +1048,9 @@ async function httpFetch (fetchParams) {
1048
1048
// and the connection uses HTTP/2, then user agents may, and are even
1049
1049
// encouraged to, transmit an RST_STREAM frame.
1050
1050
// See, https://github.com/whatwg/fetch/issues/1288
1051
- fetchParams . controller . connection . destroy ( )
1051
+ if ( request . redirect !== 'manual' ) {
1052
+ fetchParams . controller . connection . destroy ( )
1053
+ }
1052
1054
1053
1055
// 2. Switch on request’s redirect mode:
1054
1056
if ( request . redirect === 'error' ) {
Original file line number Diff line number Diff line change @@ -304,6 +304,34 @@ test('redirect with body', (t) => {
304
304
} )
305
305
} )
306
306
307
+ test ( 'redirect with stream' , ( t ) => {
308
+ t . plan ( 3 )
309
+
310
+ const location = '/asd'
311
+ const body = 'hello!'
312
+ const server = createServer ( async ( req , res ) => {
313
+ res . writeHead ( 302 , { location } )
314
+ let count = 0
315
+ const l = setInterval ( ( ) => {
316
+ res . write ( body [ count ++ ] )
317
+ if ( count === body . length ) {
318
+ res . end ( )
319
+ clearInterval ( l )
320
+ }
321
+ } , 50 )
322
+ } )
323
+ t . teardown ( server . close . bind ( server ) )
324
+
325
+ server . listen ( 0 , async ( ) => {
326
+ const res = await fetch ( `http://localhost:${ server . address ( ) . port } ` , {
327
+ redirect : 'manual'
328
+ } )
329
+ t . equal ( res . status , 302 )
330
+ t . equal ( res . headers . get ( 'location' ) , location )
331
+ t . equal ( await res . text ( ) , body )
332
+ } )
333
+ } )
334
+
307
335
test ( 'fail to extract locked body' , ( t ) => {
308
336
t . plan ( 1 )
309
337
You can’t perform that action at this time.
0 commit comments