Skip to content

Commit a364cb1

Browse files
committed
debug: adds debug statements related to Set-Cookie and issecure
1 parent 8f0a1c4 commit a364cb1

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
@@ -228,6 +228,7 @@ function session(options) {
228228
}
229229

230230
if (!shouldSetCookie(req)) {
231+
debug('should not set cookie');
231232
return;
232233
}
233234

@@ -240,6 +241,7 @@ function session(options) {
240241
if (!touched) {
241242
// touch session
242243
req.session.touch()
244+
debug('touch session');
243245
touched = true
244246
}
245247

@@ -631,17 +633,21 @@ function hash(sess) {
631633
function issecure(req, trustProxy) {
632634
// socket is https server
633635
if (req.connection && req.connection.encrypted) {
636+
debug('connection encrypted');
634637
return true;
635638
}
636639

637640
// do not trust proxy
638641
if (trustProxy === false) {
642+
debug('proxy untrusted');
639643
return false;
640644
}
641645

642646
// no explicit trust; try req.secure from express
643647
if (trustProxy !== true) {
644-
return req.secure === true
648+
var reqSecure = req.secure === true
649+
debug('request %s', reqSecure ? 'secure' : 'insecure');
650+
return reqSecure
645651
}
646652

647653
// read the proto from x-forwarded-proto header
@@ -651,7 +657,9 @@ function issecure(req, trustProxy) {
651657
? header.substr(0, index).toLowerCase().trim()
652658
: header.toLowerCase().trim()
653659

654-
return proto === 'https';
660+
var protoSecure = proto === 'https';
661+
debug('protocol %s', protoSecure ? 'secure' : 'insecure');
662+
return protoSecure;
655663
}
656664

657665
/**

0 commit comments

Comments
 (0)