File tree 3 files changed +16
-3
lines changed
3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -134,7 +134,20 @@ common.getPort = function(req) {
134
134
135
135
return res ?
136
136
res [ 1 ] :
137
- req . connection . pair ? '443' : '80' ;
137
+ common . hasEncryptedConnection ( req ) ? '443' : '80' ;
138
+ } ;
139
+
140
+ /**
141
+ * Check if the request has an encrypted connection.
142
+ *
143
+ * @param {Request } req Incoming HTTP request.
144
+ *
145
+ * @return {Boolean } Whether the connection is encrypted or not.
146
+ *
147
+ * @api private
148
+ */
149
+ common . hasEncryptedConnection = function ( req ) {
150
+ return Boolean ( req . connection . encrypted || req . connection . pair ) ;
138
151
} ;
139
152
140
153
/**
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ web_o = Object.keys(web_o).map(function(pass) {
64
64
function XHeaders ( req , res , options ) {
65
65
if ( ! options . xfwd ) return ;
66
66
67
- var encrypted = req . isSpdy || req . connection . encrypted || req . connection . pair ;
67
+ var encrypted = req . isSpdy || common . hasEncryptedConnection ( req ) ;
68
68
var values = {
69
69
for : req . connection . remoteAddress || req . socket . remoteAddress ,
70
70
port : common . getPort ( req ) ,
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ var passes = exports;
57
57
var values = {
58
58
for : req . connection . remoteAddress || req . socket . remoteAddress ,
59
59
port : common . getPort ( req ) ,
60
- proto : req . connection . pair ? 'wss' : 'ws'
60
+ proto : common . hasEncryptedConnection ( req ) ? 'wss' : 'ws'
61
61
} ;
62
62
63
63
[ 'for' , 'port' , 'proto' ] . forEach ( function ( header ) {
You can’t perform that action at this time.
0 commit comments