Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get HTTP version of incoming request

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'
});
like image 750
Ben Diamant Avatar asked Jun 15 '16 08:06

Ben Diamant


People also ask

How do I find the HTTP version?

In Google Chrome and Brave, you can easily use the Developer tools (F12 or Command + Option + I ). Open the Network tab, find the request, click the Header tab, scroll down to "Response Headers", and click view source . It should show the HTTP version in the first line.

What does get HTTP 1. 1 do?

HTTP 1.1 is the latest version of Hypertext Transfer Protocol (HTTP), the World Wide Web application protocol that runs on top of the Internet's TCP/IP suite of protocols. HTTP 1.1 provides faster delivery of Web pages than the original HTTP and reduces Web traffic.


1 Answers

Try this:

app.use('/', (req, res, next) => {
    console.log('Request HTTP Version: ', req.httpVersion)
});
like image 154
LuisPinto Avatar answered Sep 21 '22 16:09

LuisPinto