-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
Open
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.
Description
Version
v22.16.0
Platform
Linux Desktop 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 GNU/Linux
Subsystem
Debian
What steps will reproduce the bug?
import http from 'http';
const server = http.createServer((req, res) => {
if (req.method === 'LIST' && req.url === '/list') {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ message: 'List request received' }));
} else {
res.writeHead(404, { 'Content-Type': 'text/plain' });
res.end('Not Found');
}
});
server.listen(3000, () => {
console.log('Server is listening on port 3000');
});
const options = {
hostname: 'localhost',
port: 3000,
path: '/list',
method: 'LIST',
};
const req = http.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log('Response:', data); //data is empty!
});
});
req.on('error', (error) => {
console.error('Error:', error);
});
req.end();How often does it reproduce? Is there a required condition?
Every time
What is the expected behavior? Why is that the expected behavior?
Node should throw/emit error because the LIST method is not supported.
What do you see instead?
The "end' response event is emitted even though the request never reaches the server.
Additional information
The llhttp parser returns an error:
NODE_DEBUG=* ..
HTTP 183038: parse error [Error: Parse Error: Invalid method encountered] {
bytesParsed: 2,
code: 'HPE_INVALID_METHOD',
reason: 'Invalid method encountered',
rawPacket: <Buffer 4c 49 ...>
}
Metadata
Metadata
Assignees
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.