File tree 1 file changed +19
-6
lines changed
1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change 1
1
var http = require ( 'http' ) ,
2
2
https = require ( 'https' ) ,
3
+ util = require ( 'util' ) ,
3
4
common = require ( '../common' ) ,
4
5
passes = exports ;
5
6
@@ -113,12 +114,24 @@ var passes = exports;
113
114
114
115
if ( proxyHead && proxyHead . length ) proxySocket . unshift ( proxyHead ) ;
115
116
116
- socket . write ( 'HTTP/1.1 101 Switching Protocols\r\n' ) ;
117
- socket . write ( proxyRes . rawHeaders . map ( function ( v , i , a ) {
118
- return ! ( i % 2 ) ? v + ": " + a [ i + 1 ] : null ;
119
- } ) . filter ( function ( v ) {
120
- return v ? true : false ;
121
- } ) . join ( '\r\n' ) + '\r\n\r\n' ) ;
117
+ var writeHead = [
118
+ 'HTTP/1.1 101 Switching Protocols'
119
+ ] ;
120
+
121
+ Object . keys ( proxyRes . headers ) . map ( function ( i ) {
122
+ if ( util . isArray ( proxyRes . headers [ i ] ) ) {
123
+ var a = proxyRes . headers [ i ] ;
124
+ var len = a . length ;
125
+
126
+ for ( var x = 0 ; x < len ; x ++ ) {
127
+ writeHead . push ( i + ": " + a [ x ] ) ;
128
+ }
129
+ } else {
130
+ writeHead . push ( i + ": " + proxyRes . headers [ i ] ) ;
131
+ }
132
+ } ) ;
133
+
134
+ socket . write ( writeHead . join ( '\r\n' ) + '\r\n\r\n' ) ;
122
135
proxySocket . pipe ( socket ) . pipe ( proxySocket ) ;
123
136
124
137
server . emit ( 'open' , proxySocket ) ;
You can’t perform that action at this time.
0 commit comments