Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

https server / req.socket.socket #758

Closed
fabrizim opened this issue Mar 8, 2011 · 7 comments
Closed

https server / req.socket.socket #758

fabrizim opened this issue Mar 8, 2011 · 7 comments

Comments

@fabrizim
Copy link

fabrizim commented Mar 8, 2011

When running an https server with express, I noticed that when I lit up a logger and tried to print the remoteAddress, it was printing 'undefined'. After some investigation, I found that the socket object in the request was missing the remoteAddress property. I also found that req.socket had a socket property as well.

To work around this for logging purposes, I just added my own little middleware function:

function(req,res, next){
    if( req.socket.socket ){
        req.socket.remoteAddress = req.socket.socket.remoteAddress;
    }
    next();
};

However, I think this indicates a larger problem that may affect other code expecting missing properties from the req.socket object within the https module.

Should there be consistency between the servers created with http and https?

@sh1mmer
Copy link

sh1mmer commented Oct 24, 2011

HTTPS uses the TLS module which provides the CleartextStream class. This is a stream implementation with a socket in it. This is why you see this behaviour. It's expected, but I agree it is a little strange. I'm going to mark this as a feature request to get some discussion about it.

@koichik
Copy link

koichik commented Oct 26, 2011

@ry @bnoordhuis - Can you review?

@bnoordhuis
Copy link
Member

@koichik: LGTM

@koichik
Copy link

koichik commented Oct 26, 2011

@bnoordhuis - Thanks, merging.

@koichik
Copy link

koichik commented Oct 26, 2011

@fabrizim - Thanks for the report.

@fabrizim
Copy link
Author

Glad I could help - thanks for looking into it and making things modules more consistent.

@sh1mmer
Copy link

sh1mmer commented Oct 31, 2011

@fabrizim do you have a test case for this? Can you replicate with HEAD?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants