Get HTTP version of incoming request
Asked Answered
D

2

9

How can I extract the HTTP version of an incoming request using express?

I need something like:

app.use('/', (req, res, next) => {
    req.getHttpVersion() // 'HTTP 1.0'/'HTTP 1.1'/'HTTP 2.0'
});
Drayman answered 15/6, 2016 at 8:9 Comment(0)
L
11

Try this:

app.use('/', (req, res, next) => {
    console.log('Request HTTP Version: ', req.httpVersion)
});
Liv answered 15/6, 2016 at 11:34 Comment(0)
A
0

I know tis is old , but still.. you can try :

app.use('/', (req, res, next) => {
    console.log('AlpnProtocol: ' , req.connection.alpnProtocol,)
});
Armenta answered 4/5, 2020 at 11:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.