Commit 12e70fa 1 parent 533881f commit 12e70fa Copy full SHA for 12e70fa
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 @@ -404,7 +404,7 @@ function connectionListener(socket) {
404
404
}
405
405
}
406
406
407
- if ( socket . _paused ) {
407
+ if ( socket . _paused && socket . parser ) {
408
408
// onIncoming paused the socket, we should pause the parser as well
409
409
debug ( 'pause parser' ) ;
410
410
socket . parser . pause ( ) ;
@@ -445,7 +445,8 @@ function connectionListener(socket) {
445
445
// If we previously paused, then start reading again.
446
446
if ( socket . _paused && ! needPause ) {
447
447
socket . _paused = false ;
448
- socket . parser . resume ( ) ;
448
+ if ( socket . parser )
449
+ socket . parser . resume ( ) ;
449
450
socket . resume ( ) ;
450
451
}
451
452
}
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