Phalcode / gamevault-backend

Backend for the self-hosted gaming platform for drm-free games
https://gamevau.lt
Other
156 stars 13 forks source link

The Range header is non-inclusive #298

Closed mjishnu closed 1 month ago

mjishnu commented 1 month ago

Describe the bug The range header provided by Api endpoint is non inclusive this prevents concurrent downloaders which uses range headers to produce corrupt parts

expected: Range: bytes=0-499 should give 500 bytes actual: Range: bytes=0-499 gives 499 bytes

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range

Reproduce

trying to download OpenTTD with a size of 7304357 bytes from demo server.

curl -X 'GET' \
  'https://demo.gamevau.lt/api/games/5/download' \
  -H 'accept: application/json' \
  -H 'Range: 0-7304356' \
  -H 'Authorization: Basic ZGVtbzpkZW1vZGVtbw=='
curl -X 'GET' \
  'https://demo.gamevau.lt/api/games/5/download' \
  -H 'accept: application/json' \
  -H 'Range: 0-7304357' \
  -H 'Authorization: Basic ZGVtbzpkZW1vZGVtbw=='

the first curl gives a corrupt file, where as the 2nd one gives the correct file, this is not the desired behavior as http range headers should be inclusive first curl should produce the correct file.

Alfagun74 commented 1 month ago

Thanks for reporting and fixing this oversight, it will release with the next gamevault-backend version.