获取传入请求的HTTP版本

时间:2022-02-26 20:15:20

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

如何使用express提取传入请求的HTTP版本?

I need something like:

我需要这样的东西:

app.use('/', (req, res, next) => {
    req.getHttpVersion() // 'HTTP 1.0'/'HTTP 1.1'/'HTTP 2.0'
});

1 个解决方案

#1


3  

Try this:

尝试这个:

app.use('/', (req, res, next) => {
    console.log('Request HTTP Version: ', req.httpVersion)
});

#1


3  

Try this:

尝试这个:

app.use('/', (req, res, next) => {
    console.log('Request HTTP Version: ', req.httpVersion)
});