@@ -5,69 +5,19 @@ if (!common.hasCrypto)
55 common . skip ( 'missing crypto' ) ;
66const assert = require ( 'assert' ) ;
77const { createServer } = require ( 'https' ) ;
8- const { connect } = require ( 'tls' ) ;
98const fixtures = require ( '../common/fixtures' ) ;
109
1110const options = {
1211 key : fixtures . readKey ( 'agent1-key.pem' ) ,
1312 cert : fixtures . readKey ( 'agent1-cert.pem' )
1413} ;
1514
16- // This test validates that the server returns 408
17- // after server.requestTimeout if the client
18- // pauses before start sending the body.
19-
20- const server = createServer ( options , common . mustCall ( ( req , res ) => {
21- let body = '' ;
22- req . setEncoding ( 'utf-8' ) ;
23-
24- req . on ( 'data' , ( chunk ) => {
25- body += chunk ;
26- } ) ;
27-
28- req . on ( 'end' , ( ) => {
29- res . writeHead ( 200 , { 'Content-Type' : 'text/plain' } ) ;
30- res . write ( body ) ;
31- res . end ( ) ;
32- } ) ;
33- } ) ) ;
15+ const server = createServer ( options ) ;
3416
3517// 0 seconds is the default
3618assert . strictEqual ( server . requestTimeout , 0 ) ;
3719const requestTimeout = common . platformTimeout ( 1000 ) ;
3820server . requestTimeout = requestTimeout ;
3921assert . strictEqual ( server . requestTimeout , requestTimeout ) ;
4022
41- server . listen ( 0 , common . mustCall ( ( ) => {
42- const client = connect ( {
43- host : '127.0.0.1' ,
44- port : server . address ( ) . port ,
45- rejectUnauthorized : false
46- } ) ;
47- let response = '' ;
48-
49- client . on ( 'data' , common . mustCall ( ( chunk ) => {
50- response += chunk . toString ( 'utf-8' ) ;
51- } ) ) ;
52-
53- client . resume ( ) ;
54- client . write ( 'POST / HTTP/1.1\r\n' ) ;
55- client . write ( 'Content-Length: 20\r\n' ) ;
56- client . write ( 'Connection: close\r\n' ) ;
57- client . write ( '\r\n' ) ;
58-
59- setTimeout ( ( ) => {
60- client . write ( '12345678901234567890\r\n\r\n' ) ;
61- } , common . platformTimeout ( 2000 ) ) . unref ( ) ;
62-
63- const errOrEnd = common . mustCall ( function ( err ) {
64- assert . strictEqual (
65- response ,
66- 'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n'
67- ) ;
68- server . close ( ) ;
69- } ) ;
70-
71- client . on ( 'end' , errOrEnd ) ;
72- client . on ( 'error' , errOrEnd ) ;
73- } ) ) ;
23+ server . close ( ) ;
0 commit comments