Description
- Version: tested on Node v14.15.4, v15.6.0 and v14.7.x
- Platform: Linux 5.4.51-v7l+ armv7l GNU/Linux (it's a Raspberry Pi 4 running Debian 10)
- Subsystem: http
What steps will reproduce the bug?
Run the following:
const http = require(`http`)
const url = `http://51.77.66.14/Trilogia%20%20John%20Wick%202014-2019%20REMUX%204K%20HDR%20Latino/John%20Wick%203%20Parabellum%202019%20REMUX%204K%20HDR%20Latino.mkv`
const byteOffset = 2595000000
const req = http.request(url, {
method: `GET`,
headers: {
'Range': `bytes=${byteOffset}-`,
}
}, (res) => {
console.log(`STATUS:`, res.statusCode);
console.log(`HEADERS:`, res.headers);
// res.setEncoding('hex');
res.on('data', (chunk) => {
// needs to be registered so that the body is parsed
});
})
req.on('error', (err) => {
console.error(err)
});
req.end();
How often does it reproduce? Is there a required condition?
One this platform, always.
What is the expected behavior?
No error, the response should be parsed just fine. I know the responding web server might be (at least partially) at fault, but the issue does not appear on win32 (Windows 10) or in Linux/WSL1 (openSUSE & Debian) on x64, so this probably isn't desired behavior.
For what it's worth, both curl
and wget
don't face this issue either.
What do you see instead?
STATUS: 206
HEADERS: {
date: 'Sun, 24 Jan 2021 18:03:49 GMT',
server: 'Apache/2.4.29 (Ubuntu)',
'last-modified': 'Sun, 05 Jan 2020 20:21:31 GMT',
etag: '"f9ac35f5c-59b6a49dd4bc5"',
'accept-ranges': 'bytes',
'content-length': '64426004636',
'content-range': 'bytes 2595000000-67021004635/67021004636',
connection: 'close',
'content-type': 'video/x-matroska'
}
Error: Parse Error: Expected HTTP/
at Socket.socketOnData (_http_client.js:509:22)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
bytesParsed: 335,
code: 'HPE_INVALID_CONSTANT',
reason: 'Expected HTTP/',
rawPacket: <Buffer 9a 40 a4 1b 3b aa 46 a5 7e e7 09 dd 35 3f 9e 93 b6 bc 75 3e 04 ac dc e6 f8 cd 99 c4 7f 07 98 0c e7 f9 c3 2c e8 d2 20 ff d0 98 98 48 c0 ef 07 66 60 5d ... 1350 more bytes>
}
Additional information
The requested file is quite large, so if it doesn't throw an error after a few seconds, don't wait for it to finish. I wish I had another URL to shared, but right now I only have this one. Although I am very sure I've encountered this error several times before (but didn't look into it further).
Also, notice the byteOffset
. The issue happens at a specific byte range, hence the offset. The offset isn't totally exact, but should narrow it down to a few megabytes...
I really hope someone can figure out what's going on here. I'm building a download manager and it's very unfortunate that it doesn't work reliably on my server...