Skip to content

handle ranged requests for proxied files - fixes #494

dakkar requested to merge feature/494-return-206-when-needed into develop

What does this PR do?

When configured to proxyRemoteFiles, Misskey would download the remote file for each request, then stream it out again. As part of this, it tries to correctly handle the Range header. But this was not really working. Here I fix two problems:

  1. two code paths were handling ranged requests but not setting the response code to 206, confusing the clients
  2. remote files don't have their size stored in the database (correctly, because it can change!), but also we weren't detecting the size after downloading them, which disabled the range handling (again, sensible: you can't send a portion of a file if you don't know how bit the file is!)

Tested with firefox, by disabling all caching, and checking the network inspector to see what requests and responses were actually performed. Before, Sharkey always sent 200 and the whole file; after, it sends 206 and the section that the browser actually requested.

Thanks to @dalekcoffee@oshi.social and @kopper for the investigation!

Contribution Guidelines By submitting this merge request, you agree to follow our Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines
  • I have made sure to test this pull request

Merge request reports