File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -42,3 +42,29 @@ const http = require('http');
4242 req . emit ( 'abort' ) ;
4343 assert . strictEqual ( signal . aborted , true ) ;
4444}
45+
46+ // Test 5: res.signal on a client-side http.request() response (IncomingMessage).
47+ {
48+ const server = http . createServer ( common . mustCall ( ( req , res ) => {
49+ res . writeHead ( 200 ) ;
50+ res . write ( 'partial' ) ;
51+ } ) ) ;
52+
53+ server . listen ( 0 , common . mustCall ( ( ) => {
54+ const clientReq = http . request (
55+ { port : server . address ( ) . port } ,
56+ common . mustCall ( ( res ) => {
57+ assert . ok ( res . signal instanceof AbortSignal ) ;
58+ assert . strictEqual ( res . signal . aborted , false ) ;
59+
60+ res . signal . onabort = common . mustCall ( ( ) => {
61+ assert . strictEqual ( res . signal . aborted , true ) ;
62+ server . close ( ) ;
63+ } ) ;
64+ clientReq . destroy ( ) ;
65+ } ) ,
66+ ) ;
67+ clientReq . on ( 'error' , ( ) => { } ) ;
68+ clientReq . end ( ) ;
69+ } ) ) ;
70+ }
You can’t perform that action at this time.
0 commit comments