File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ // Flags: --http-parser=legacy
2+ 'use strict' ;
3+
4+ const common = require ( '../common' ) ;
5+
6+ const assert = require ( 'assert' ) ;
7+ const http = require ( 'http' ) ;
8+ const net = require ( 'net' ) ;
9+
10+ const msg = [
11+ 'POST / HTTP/1.1' ,
12+ 'Host: 127.0.0.1' ,
13+ 'Transfer-Encoding: chunked' ,
14+ 'Transfer-Encoding: chunked-false' ,
15+ 'Connection: upgrade' ,
16+ '' ,
17+ '1' ,
18+ 'A' ,
19+ '0' ,
20+ '' ,
21+ 'GET /flag HTTP/1.1' ,
22+ 'Host: 127.0.0.1' ,
23+ '' ,
24+ '' ,
25+ ] . join ( '\r\n' ) ;
26+
27+ // Verify that the server is called only once even with a smuggled request.
28+
29+ const server = http . createServer ( common . mustCall ( ( req , res ) => {
30+ res . end ( ) ;
31+ } , 1 ) ) ;
32+
33+ function send ( next ) {
34+ const client = net . connect ( server . address ( ) . port , 'localhost' ) ;
35+ client . setEncoding ( 'utf8' ) ;
36+ client . on ( 'error' , common . mustNotCall ( ) ) ;
37+ client . on ( 'end' , next ) ;
38+ client . write ( msg ) ;
39+ client . resume ( ) ;
40+ }
41+
42+ server . listen ( 0 , common . mustCall ( ( err ) => {
43+ assert . ifError ( err ) ;
44+ send ( common . mustCall ( ( ) => {
45+ server . close ( ) ;
46+ } ) ) ;
47+ } ) ) ;
You can’t perform that action at this time.
0 commit comments