File tree 2 files changed +70
-0
lines changed
2 files changed +70
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Flags: --insecure-http-parser --http-parser=legacy
2
+
3
+ 'use strict' ;
4
+ const common = require ( '../common' ) ;
5
+ const assert = require ( 'assert' ) ;
6
+ const http = require ( 'http' ) ;
7
+ const net = require ( 'net' ) ;
8
+
9
+ const server = http . createServer ( function ( req , res ) {
10
+ assert . strictEqual ( req . headers [ 'content-type' ] , 'text/te\bt' ) ;
11
+ req . pipe ( res ) ;
12
+ } ) ;
13
+
14
+ server . listen ( 0 , common . mustCall ( function ( ) {
15
+ const bufs = [ ] ;
16
+ const client = net . connect (
17
+ this . address ( ) . port ,
18
+ function ( ) {
19
+ client . write (
20
+ 'GET / HTTP/1.1\r\n' +
21
+ 'Content-Type: text/te\x08t\r\n' +
22
+ 'Connection: close\r\n\r\n' ) ;
23
+ }
24
+ ) ;
25
+ client . on ( 'data' , function ( chunk ) {
26
+ bufs . push ( chunk ) ;
27
+ } ) ;
28
+ client . on ( 'end' , common . mustCall ( function ( ) {
29
+ const head = Buffer . concat ( bufs )
30
+ . toString ( 'latin1' )
31
+ . split ( '\r\n' ) [ 0 ] ;
32
+ assert . strictEqual ( head , 'HTTP/1.1 200 OK' ) ;
33
+ server . close ( ) ;
34
+ } ) ) ;
35
+ } ) ) ;
Original file line number Diff line number Diff line change
1
+ // Flags: --insecure-http-parser
2
+
3
+ 'use strict' ;
4
+ const common = require ( '../common' ) ;
5
+ const assert = require ( 'assert' ) ;
6
+ const http = require ( 'http' ) ;
7
+ const net = require ( 'net' ) ;
8
+
9
+ const server = http . createServer ( function ( req , res ) {
10
+ assert . strictEqual ( req . headers [ 'content-type' ] , 'text/te\bt' ) ;
11
+ req . pipe ( res ) ;
12
+ } ) ;
13
+
14
+ server . listen ( 0 , common . mustCall ( function ( ) {
15
+ const bufs = [ ] ;
16
+ const client = net . connect (
17
+ this . address ( ) . port ,
18
+ function ( ) {
19
+ client . write (
20
+ 'GET / HTTP/1.1\r\n' +
21
+ 'Content-Type: text/te\x08t\r\n' +
22
+ 'Connection: close\r\n\r\n' ) ;
23
+ }
24
+ ) ;
25
+ client . on ( 'data' , function ( chunk ) {
26
+ bufs . push ( chunk ) ;
27
+ } ) ;
28
+ client . on ( 'end' , common . mustCall ( function ( ) {
29
+ const head = Buffer . concat ( bufs )
30
+ . toString ( 'latin1' )
31
+ . split ( '\r\n' ) [ 0 ] ;
32
+ assert . strictEqual ( head , 'HTTP/1.1 200 OK' ) ;
33
+ server . close ( ) ;
34
+ } ) ) ;
35
+ } ) ) ;
You can’t perform that action at this time.
0 commit comments