Skip to content

Invalid HTTP method incorrectly returns a 400 instead of a 405 #17248

@Qix-

Description

@Qix-
const http = require('http');

const srv = http.createServer((req, res) => {
	res.writeHead(200, { 'Content-Type': 'text/plain' });
	res.end('okay');
});

srv.listen(3210);
$ curl -vv localhost:3210 -XOHAI
* Rebuilt URL to: localhost:3210/
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 3210 (#0)
> OHAI / HTTP/1.1
> Host: localhost:3210
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 400 Bad Request
* no chunk, no close, no size. Assume close to signal end
<
* Closing connection 0

This should be sending a 405 Method Not Allowed, not a 400.

Also, preferably, Node shouldn't care about the method and should happily forward it along in the req.method field. But I know that's asking for too much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues or PRs related to the http subsystem.questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions