StatusCode not properly shown for WebSocket request in Morgan
Closed this issue · 3 comments
Morgan checks for res._header instead of res.headers to show statusCode. It is suggested to define the extra properties this._header = this._headers in line 10. By the way, any hints to define writeHead so that Morgan on-header modules can properly record the datetime once writeHead is called.
function MockServerResponse(finish) {
Transform.call(this);
this.statusCode = 200;
this._header = this._headers = {};
if (typeof finish === 'function')
this.on('finish', finish);
}
I am not familiar with Morgan...please submit a pull request, with tests if applicable
The following is Morgan output with "_header" defined. Response time can also be shown with minor change in Morgan. It seems that "content-length" cannot be provided in websocket req.
Please review.
GET /api/user?limit=10&skip=0 200 1742.797 ms - -
GET /api/roster?limit=10&skip=0 200 1808.194 ms - -
PUT /api/user/me 200 1801.649 ms - -
GET /im.app/lib/ionic/fonts/ionicons.ttf?v=2.0.1 304 1.313 ms - -
GET /im.app/templates/user/status.html 304 2.037 ms -
Fixed in 0.3.0