Skip to content

Commit 89f198c

Browse files
authored
lib: use req.socket over deprecated req.connection (#6705)
Signed-off-by: Sebastian Beltran <[email protected]>
1 parent d9a62f9 commit 89f198c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/request.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,12 @@ req.is = function is(types) {
282282
*/
283283

284284
defineGetter(req, 'protocol', function protocol(){
285-
var proto = this.connection.encrypted
285+
var proto = this.socket.encrypted
286286
? 'https'
287287
: 'http';
288288
var trust = this.app.get('trust proxy fn');
289289

290-
if (!trust(this.connection.remoteAddress, 0)) {
290+
if (!trust(this.socket.remoteAddress, 0)) {
291291
return proto;
292292
}
293293

@@ -406,7 +406,7 @@ defineGetter(req, 'host', function host(){
406406
var trust = this.app.get('trust proxy fn');
407407
var val = this.get('X-Forwarded-Host');
408408

409-
if (!val || !trust(this.connection.remoteAddress, 0)) {
409+
if (!val || !trust(this.socket.remoteAddress, 0)) {
410410
val = this.get('Host');
411411
} else if (val.indexOf(',') !== -1) {
412412
// Note: X-Forwarded-Host is normally only ever a

test/req.protocol.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('req', function(){
3939
app.enable('trust proxy');
4040

4141
app.use(function(req, res){
42-
req.connection.encrypted = true;
42+
req.socket.encrypted = true;
4343
res.end(req.protocol);
4444
});
4545

0 commit comments

Comments
 (0)