@@ -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) {
579581function 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