File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const common = require ( '../common' ) ;
4+ if ( ! common . hasCrypto )
5+ common . skip ( 'missing crypto' ) ;
6+ const assert = require ( 'assert' ) ;
7+ const h2 = require ( 'http2' ) ;
8+
9+ // The purpose of this test is to ensure that res.finished is
10+ // not true before res.end() is called or the request is aborted
11+ // for HEAD requests.
12+
13+ const server = h2
14+ . createServer ( )
15+ . listen ( 0 , common . mustCall ( function ( ) {
16+ const port = server . address ( ) . port ;
17+ server . once ( 'request' , common . mustCall ( ( req , res ) => {
18+ assert . ok ( ! res . finished ) ; // This fails.
19+ res . end ( ) ;
20+ } ) ) ;
21+
22+ const url = `http://localhost:${ port } ` ;
23+ const client = h2 . connect ( url , common . mustCall ( function ( ) {
24+ const headers = {
25+ ':path' : '/' ,
26+ ':method' : 'HEAD' ,
27+ ':scheme' : 'http' ,
28+ ':authority' : `localhost:${ port } `
29+ } ;
30+ const request = client . request ( headers ) ;
31+ request . on ( 'end' , common . mustCall ( function ( ) {
32+ client . close ( ) ;
33+ } ) ) ;
34+ request . end ( ) ;
35+ request . resume ( ) ;
36+ } ) ) ;
37+ } ) )
You can’t perform that action at this time.
0 commit comments