{"action":"created","issue":{"url":"https://api.github.com/repos/expressjs/morgan/issues/113","repository_url":"https://api.github.com/repos/expressjs/morgan","labels_url":"https://api.github.com/repos/expressjs/morgan/issues/113/labels{/name}","comments_url":"https://api.github.com/repos/expressjs/morgan/issues/113/comments","events_url":"https://api.github.com/repos/expressjs/morgan/issues/113/events","html_url":"https://github.com/expressjs/morgan/issues/113","id":163403157,"number":113,"title":"HTTP/2 logged as HTTP 1.1","user":{"login":"receptor","id":491218,"avatar_url":"https://avatars.githubusercontent.com/u/491218?v=3","gravatar_id":"","url":"https://api.github.com/users/receptor","html_url":"https://github.com/receptor","followers_url":"https://api.github.com/users/receptor/followers","following_url":"https://api.github.com/users/receptor/following{/other_user}","gists_url":"https://api.github.com/users/receptor/gists{/gist_id}","starred_url":"https://api.github.com/users/receptor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/receptor/subscriptions","organizations_url":"https://api.github.com/users/receptor/orgs","repos_url":"https://api.github.com/users/receptor/repos","events_url":"https://api.github.com/users/receptor/events{/privacy}","received_events_url":"https://api.github.com/users/receptor/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-01T14:07:27Z","updated_at":"2016-07-01T14:23:45Z","closed_at":"2016-07-01T14:23:45Z","body":"Using Node v6.2.2 with http2 v3.3.4 express v4.14.0, morgan v1.7.0\r\n\r\n```\r\n'use strict'\r\n\r\nconst express = require('express')\r\nconst favicon = require('serve-favicon')\r\nconst app = express()\r\nconst spdy = require('spdy')\r\nconst fs = require('fs')\r\nconst morgan = require('morgan')\r\n\r\nconst options = {\r\n\tkey: fs.readFileSync(__dirname + '/snakeoil.key'),\r\n\tcert: fs.readFileSync(__dirname + '/snakeoil.crt')\r\n};\r\n\r\nfunction handler(req, res)\r\n{\r\n\tconsole.log('HTTP/2', req.isSpdy, 'version', req.spdyVersion)\r\n\t\r\n\tres.push('/main.js',\r\n\t\t{\r\n\t\t\trequest:\r\n\t\t\t{\r\n\t\t\t\taccept: '*/\\*'\r\n\t\t\t},\r\n\t\t\tresponse:\r\n\t\t\t{\r\n\t\t\t\t'content-type': 'application/javascript'\r\n\t\t\t}\r\n\t\t})\r\n\t\t.end('console.log(\"Hello World\");')\r\n\r\n\tres.writeHead(200)\r\n\tres.end('<script src=\"/main.js\"></script>')\r\n}\r\n\r\napp.use(morgan('combined'))\r\napp.use(favicon(__dirname + '/favicon.ico'))\r\napp.get('/', handler)\r\n\r\nconst server = spdy.createServer(options, app)\r\nserver.listen(8000)\r\nconsole.log('HTTP/2 Server, listening on port 8000')\r\n```\r\n\r\nFor an HTTP/2 request, this will log:\r\nHTTP/2 true version 4\r\n::ffff:10.1.0.11 - - [01/Jul/2016:13:53:41 +0000] \"GET / HTTP/1.1\" 200 - \"-\" \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36\"\r\n\r\nLooks like Morgan doesn't recognize HTTP/2 requests\r\n"},"comment":{"url":"https://api.github.com/repos/expressjs/morgan/issues/comments/229960140","html_url":"https://github.com/expressjs/morgan/issues/113#issuecomment-229960140","issue_url":"https://api.github.com/repos/expressjs/morgan/issues/113","id":229960140,"user":{"login":"dougwilson","id":67512,"avatar_url":"https://avatars.githubusercontent.com/u/67512?v=3","gravatar_id":"","url":"https://api.github.com/users/dougwilson","html_url":"https://github.com/dougwilson","followers_url":"https://api.github.com/users/dougwilson/followers","following_url":"https://api.github.com/users/dougwilson/following{/other_user}","gists_url":"https://api.github.com/users/dougwilson/gists{/gist_id}","starred_url":"https://api.github.com/users/dougwilson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dougwilson/subscriptions","organizations_url":"https://api.github.com/users/dougwilson/orgs","repos_url":"https://api.github.com/users/dougwilson/repos","events_url":"https://api.github.com/users/dougwilson/events{/privacy}","received_events_url":"https://api.github.com/users/dougwilson/received_events","type":"User","site_admin":false},"created_at":"2016-07-01T14:23:45Z","updated_at":"2016-07-01T14:23:45Z","body":"Hi! This is a problem with whatever HTTP server you are using, not Morgan. You can see our code here: https://github.com/expressjs/morgan/blob/master/index.js#L301-L303\r\n\r\nAll we do is report the `req.httpVersionMajor` and the `req.httpVersionMinor` properties, so it sounds like your server is populating those properties incorrectly. If I set those two 2 and 0, then Morgan properly prints the log as HTTP/2.0."}}
{"actor":{"display_login":"dougwilson"}}