@@ -716,8 +716,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, upgradeHead,
716
716
// In addition, it's important to note the closure scope here. Since
717
717
// there is no mapping of the socket to the request bound to it.
718
718
//
719
- reverseProxy . on ( 'upgrade' , function ( res , remoteSocket , head ) {
720
-
719
+ reverseProxy . on ( 'upgrade' , function ( res , remoteSocket , head ) {
721
720
//
722
721
// Prepare handshake response 'headers' and 'statusCode'.
723
722
//
@@ -741,27 +740,22 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, upgradeHead,
741
740
//
742
741
reverseProxy . once ( 'socket' , function ( revSocket ) {
743
742
revSocket . on ( 'data' , function handshake ( data ) {
744
-
745
743
// Set empty headers
746
744
var headers = '' ;
747
745
748
746
//
749
747
// If the handshake statusCode 101, concat headers.
750
748
//
751
- if ( reverseProxy . handshake . statusCode && reverseProxy . handshake . statusCode == 101 ) {
752
-
749
+ if ( reverseProxy . handshake . statusCode && reverseProxy . handshake . statusCode == 101 ) {
753
750
headers = [
754
- 'HTTP/1.1 101 Switching Protocols'
755
- , 'Upgrade: websocket'
756
- , 'Connection: Upgrade'
757
- , 'Sec-WebSocket-Accept: ' + reverseProxy . handshake . headers [ 'sec-websocket-accept' ]
751
+ 'HTTP/1.1 101 Switching Protocols' ,
752
+ 'Upgrade: websocket' ,
753
+ 'Connection: Upgrade' ,
754
+ 'Sec-WebSocket-Accept: ' + reverseProxy . handshake . headers [ 'sec-websocket-accept' ]
758
755
] ;
759
756
760
757
headers = headers . concat ( '' , '' ) . join ( '\r\n' ) ;
761
-
762
758
}
763
-
764
-
765
759
766
760
//
767
761
// Ok, kind of harmfull part of code. Socket.IO sends a hash
@@ -793,7 +787,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, upgradeHead,
793
787
//
794
788
self . emit ( 'websocket:handshake' , req , socket , head , sdata , data ) ;
795
789
// add headers to the socket
796
- socket . write ( headers + sdata ) ;
790
+ socket . write ( headers + sdata ) ;
797
791
var flushed = socket . write ( data ) ;
798
792
if ( ! flushed ) {
799
793
revSocket . pause ( ) ;
0 commit comments