Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect logger not logging remote address under Node 0.10 when Connection: Close header set #811

Closed
ruoho opened this issue May 17, 2013 · 2 comments · Fixed by #930
Closed

Comments

@ruoho
Copy link

ruoho commented May 17, 2013

The Connect logger middleware does not log the client :remote-addr correctly under Node 0.10.6 when the Connection: Close header is set on a client request. This is logged correctly with Node 0.8.23. Sample code:

var connect = require('connect');

var app = connect()
  .use(connect.logger('default'))
  .use(function(req, res){
    res.end('hello world\n');
  })
 .listen(3000);

Make two requests to the server:

$ perl -e 'print "GET /request1 HTTP/1.1\r\nHost: localhost\r\n\r\n"' | nc localhost 3000
...
$ perl -e 'print "GET /request2 HTTP/1.1\r\nConnection: close\r\nHost: localhost\r\n\r\n"' | nc localhost 3000
...

The output from connect.logger shows the following from these requests:

127.0.0.1 - - [Fri, 17 May 2013 17:31:57 GMT] "GET /request1 HTTP/1.1" 200 - "-" "-"
- - - [Fri, 17 May 2013 17:31:47 GMT] "GET /request2 HTTP/1.1" 200 - "-" "-"

In the request with the client Connection: close header set, the client's address (:remote-addr from the default logger format) is not displayed.

@jonathanong
Copy link
Contributor

hi, can you add a test?

@dougwilson
Copy link
Contributor

The only solution is to get the remote address from the socket before the socket is closed. At the time the logger is invoked to format the line, it is too late.

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

Successfully merging a pull request may close this issue.

3 participants