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'
});
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.
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.
Try this:
app.use('/', (req, res, next) => {
console.log('Request HTTP Version: ', req.httpVersion)
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With