granian icon indicating copy to clipboard operation
granian copied to clipboard

WIP: Serve partial files

Open myers opened this issue 1 year ago • 2 comments

  • [ ] needs to add header to advertise support for partial files
  • [ ] return correct response if the range requested isn't supported
  • [ ] return the whole file if the range requested is invalid
  • [ ] example should serve whole directory and check symlinks to only serve files in that directory
  • [ ] document why this is better than just read/seeking in python code
  • [ ] update RSGI spec with start, end parameters

myers avatar Dec 28 '23 15:12 myers

@myers thank you for the PR, FYI I'm AFK during these days, I'll look at this after Jan 3rd

gi0baro avatar Dec 29 '23 10:12 gi0baro

@myers I'm sorry for the late reply, but I finally managed to take a look at this. I also wanted to release 1.0 before this, as the Hyper API changed and I didn't want to add protocol changes before porting the code to Hyper 1.0, thus this will need changes to adapt the code to 1.0.

That said, I'm not super intrigued by altering response_file method with all that logic; also considering the default response code for partial content should be 206, maybe the best option here is to add an additional method to RSGI spec like response_file_partial or response_file_range, WDYT? Also, I would leave the headers management to the application, not the server itself.

gi0baro avatar Jan 25 '24 10:01 gi0baro