Deluan 79fc6fed60 fix(stream): keep the headroom in the estimated content length
5686c352c changed the estimate from bitRate / 8 * 1024 to * 1000, reading the
1024 as a unit mistake. It was headroom: the body also carries the ID3 tag, the
Xing frame and frame padding, so a nominal-size estimate is short, and net/http
aborts a response that writes past its declared Content-Length. Measured on a
live server, a 429s track at 64kbps was estimated at 3,439,840 bytes against a
3,441,569-byte body, and the stream was cut with 'http: wrote more than the
declared Content-Length'.

Restores the 1024, says why next to it, and turns the test into one that
asserts the headroom rather than a formula.
2026-09-24 17:16:41 -04:00
..