Commit dfc6f4a 1 parent e2b6d45 commit dfc6f4a Copy full SHA for dfc6f4a
File tree 2 files changed +60
-2
lines changed
2 files changed +60
-2
lines changed Original file line number Diff line number Diff line change @@ -372,7 +372,7 @@ function connectionListener(socket) {
372
372
}
373
373
}
374
374
375
- if ( socket . _paused ) {
375
+ if ( socket . _paused && socket . parser ) {
376
376
// onIncoming paused the socket, we should pause the parser as well
377
377
debug ( 'pause parser' ) ;
378
378
socket . parser . pause ( ) ;
@@ -411,7 +411,8 @@ function connectionListener(socket) {
411
411
// If we previously paused, then start reading again.
412
412
if ( socket . _paused ) {
413
413
socket . _paused = false ;
414
- socket . parser . resume ( ) ;
414
+ if ( socket . parser )
415
+ socket . parser . resume ( ) ;
415
416
socket . resume ( ) ;
416
417
}
417
418
}
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const common = require ( '../common' ) ;
3
+ const assert = require ( 'assert' ) ;
4
+ const http = require ( 'http' ) ;
5
+ const net = require ( 'net' ) ;
6
+
7
+ var once = false ;
8
+ var first = null ;
9
+ var second = null ;
10
+
11
+ const chunk = new Buffer ( 1024 ) ;
12
+ chunk . fill ( 'X' ) ;
13
+
14
+ var size = 0 ;
15
+
16
+ var more ;
17
+ var done ;
18
+
19
+ var server = http . createServer ( function ( req , res ) {
20
+ if ( ! once )
21
+ server . close ( ) ;
22
+ once = true ;
23
+
24
+ if ( first === null ) {
25
+ first = res ;
26
+ return ;
27
+ }
28
+ if ( second === null ) {
29
+ second = res ;
30
+ res . write ( chunk ) ;
31
+ } else {
32
+ res . end ( chunk ) ;
33
+ }
34
+ size += res . outputSize ;
35
+ if ( size <= req . socket . _writableState . highWaterMark ) {
36
+ more ( ) ;
37
+ return ;
38
+ }
39
+ done ( ) ;
40
+ } ) . on ( 'upgrade' , function ( req , socket ) {
41
+ second . end ( chunk , function ( ) {
42
+ socket . end ( ) ;
43
+ } ) ;
44
+ first . end ( 'hello' ) ;
45
+ } ) . listen ( common . PORT , function ( ) {
46
+ var s = net . connect ( common . PORT ) ;
47
+ more = function ( ) {
48
+ s . write ( 'GET / HTTP/1.1\r\n\r\n' ) ;
49
+ } ;
50
+ done = function ( ) {
51
+ s . write ( 'GET / HTTP/1.1\r\n\r\n' +
52
+ 'GET / HTTP/1.1\r\nConnection: upgrade\r\nUpgrade: ws\r\n\r\naaa' ) ;
53
+ } ;
54
+ more ( ) ;
55
+ more ( ) ;
56
+ s . resume ( ) ;
57
+ } ) ;
You can’t perform that action at this time.
0 commit comments