Skip to content

Commit 4427d93

Browse files
authored
debug: adds debug statements related to Set-Cookie and issecure (#986)
1 parent f5b5ebb commit 4427d93

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

index.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ function session(options) {
207207
}
208208

209209
if (!shouldSetCookie(req)) {
210+
debug('should not set cookie');
210211
return;
211212
}
212213

@@ -219,6 +220,7 @@ function session(options) {
219220
if (!touched) {
220221
// touch session
221222
req.session.touch()
223+
debug('touch session');
222224
touched = true
223225
}
224226

@@ -579,17 +581,21 @@ function hash(sess) {
579581
function issecure(req, trustProxy) {
580582
// socket is https server
581583
if (req.connection && req.connection.encrypted) {
584+
debug('connection encrypted');
582585
return true;
583586
}
584587

585588
// do not trust proxy
586589
if (trustProxy === false) {
590+
debug('proxy untrusted');
587591
return false;
588592
}
589593

590594
// no explicit trust; try req.secure from express
591595
if (trustProxy !== true) {
592-
return req.secure === true
596+
var reqSecure = req.secure === true
597+
debug('request %s', reqSecure ? 'secure' : 'insecure');
598+
return reqSecure
593599
}
594600

595601
// read the proto from x-forwarded-proto header
@@ -599,7 +605,9 @@ function issecure(req, trustProxy) {
599605
? header.substr(0, index).toLowerCase().trim()
600606
: header.toLowerCase().trim()
601607

602-
return proto === 'https';
608+
var protoSecure = proto === 'https';
609+
debug('protocol %s', protoSecure ? 'secure' : 'insecure');
610+
return protoSecure;
603611
}
604612

605613
/**

0 commit comments

Comments
 (0)