Skip to content

http module accepts all http versions (e.g. HTTP/9.9) and treats/responds to them as http1 #43115

@cmawhorter

Description

@cmawhorter

Version

14.9.2

Platform

all

Subsystem

http

What steps will reproduce the bug?

http accepts any http version and treats it as http1, and passes it along (>= 0 and <= 9.9 in my tests). this may be a feature, but if so could use some documentation since it's a little unexpected maybe.

copying comment from here:

'use strict'

const http = require('http')
const host = 'localhost'
const port = 3000
const handlerequest = function (req, res) {
  console.log(req)
  console.log(req.httpVersion)
  res.writeHead(200)
  res.end(`Your Request HTTP Version is ${req.httpVersion} 
            with Major ${req.httpVersionMajor} and Minor ${req.httpVersionMinor}`)
}
const server = http.createServer(handlerequest)
server.listen(port, host, () => {
  console.log(`Server is running on http://${host}:${port}`)
})

with:

telnet 127.0.0.1 3000
GET / HTTP/5.6

and the response is

HTTP/1.1 200 OK
Date: Sun, 15 May 2022 15:17:11 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked

46
Your Request HTTP Version is 5.6 
            with Major 5 and Minor 6
0

How often does it reproduce? Is there a required condition?

no special requirements/conditions

What is the expected behavior?

request being rejected. http 505 maybe? requesting with GET / NOTHTTP/1.1 gives 400 bad request.

What do you see instead?

the node server treats all requests regardless of version as http1

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions