[PR #4758] [MERGED] Range request support #6405

Closed
opened 2026-02-05 10:31:23 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/BookStackApp/BookStack/pull/4758
Author: @ssddanbrown
Created: 1/7/2024
Status: Merged
Merged: 1/17/2024
Merged by: @ssddanbrown

Base: developmentHead: range_request_support


📝 Commits (5)

  • b4d9029 Range requests: Extracted stream output handling to new class
  • d947625 Range requests: Added basic HTTP range support
  • 91d8d6e Range requests: Added test cases to cover functionality
  • c1552fb Attachments: Drag and drop video support
  • 2dc454d Uploads: Explicitly disabled s3 streaming in config

📊 Changes

8 files changed (+288 additions, -36 deletions)

View changed files

📝 app/Config/filesystems.php (+1 -0)
📝 app/Http/DownloadResponseFactory.php (+23 -29)
app/Http/RangeSupportedStream.php (+134 -0)
📝 app/Uploads/Attachment.php (+17 -2)
📝 app/Uploads/AttachmentService.php (+8 -2)
📝 app/Uploads/Controllers/AttachmentController.php (+3 -2)
📝 resources/views/attachments/manager-list.blade.php (+1 -1)
📝 tests/Uploads/AttachmentTest.php (+101 -0)

📄 Description

Ready for merge

Primarily for video support.
This also:

  • Sets content-length so attachment downloads can properly show progress.
  • Adds drag and drop of video into editors to add as an embedded HTML video.

Notes

In testing, all browsers handle video slightly differently.
Worked across Chrome, Firefox and Safari, with each using range headers in some way.
Couldn't get Safari to chunk though. Did an initial byte request, then consumed the rest in one go, even without playing the video, bit strange and leaves the user waiting for download if they scrub.

For cloud (S3) storage, this added functionality is only semi-supported.
Range responses to the browser will work but the full content is fetched to BookStack, then partially streamed.
Means it acts the same browser side, but not great for large video as you'll still be waiting for the full content.
Could benefit in some minor cases though, especially where app hosted close to storage.
Is possible to stream on s3-side, but can't seek, so would need a specific solution to range on that side also lower down in driver. Support for s3 services could vary there. Might also be better to use a signed url base approach depending on support.
For now, this shouldn't have any added downsides, so we'll skip any added s3-specific complexity for now.

Todo

  • Add range header support
  • Add support for head requests
  • Test in a range of browsers
  • Test content at boundaries
    • Test with length just before sniff length
    • Test with length just after sniff length
  • Test with streaming from s3-like storage
  • Cover with testing

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/BookStackApp/BookStack/pull/4758 **Author:** [@ssddanbrown](https://github.com/ssddanbrown) **Created:** 1/7/2024 **Status:** ✅ Merged **Merged:** 1/17/2024 **Merged by:** [@ssddanbrown](https://github.com/ssddanbrown) **Base:** `development` ← **Head:** `range_request_support` --- ### 📝 Commits (5) - [`b4d9029`](https://github.com/BookStackApp/BookStack/commit/b4d9029dc301f73f0e87026b8eff78cf2cda6164) Range requests: Extracted stream output handling to new class - [`d947625`](https://github.com/BookStackApp/BookStack/commit/d94762549a3ef364d4486a27f1585122f60c10ec) Range requests: Added basic HTTP range support - [`91d8d6e`](https://github.com/BookStackApp/BookStack/commit/91d8d6eaaa5ae42fc9872901d6fcbcae8e19236e) Range requests: Added test cases to cover functionality - [`c1552fb`](https://github.com/BookStackApp/BookStack/commit/c1552fb799cda7fbb6de27ebcb01aa2580fd5330) Attachments: Drag and drop video support - [`2dc454d`](https://github.com/BookStackApp/BookStack/commit/2dc454d206b518804aecd0551a71d338cf889c08) Uploads: Explicitly disabled s3 streaming in config ### 📊 Changes **8 files changed** (+288 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `app/Config/filesystems.php` (+1 -0) 📝 `app/Http/DownloadResponseFactory.php` (+23 -29) ➕ `app/Http/RangeSupportedStream.php` (+134 -0) 📝 `app/Uploads/Attachment.php` (+17 -2) 📝 `app/Uploads/AttachmentService.php` (+8 -2) 📝 `app/Uploads/Controllers/AttachmentController.php` (+3 -2) 📝 `resources/views/attachments/manager-list.blade.php` (+1 -1) 📝 `tests/Uploads/AttachmentTest.php` (+101 -0) </details> ### 📄 Description **Ready for merge** Primarily for video support. This also: - Sets content-length so attachment downloads can properly show progress. - Adds drag and drop of video into editors to add as an embedded HTML video. ## Notes In testing, all browsers handle video slightly differently. Worked across Chrome, Firefox and Safari, with each using range headers in some way. Couldn't get Safari to chunk though. Did an initial byte request, then consumed the rest in one go, even without playing the video, bit strange and leaves the user waiting for download if they scrub. For cloud (S3) storage, this added functionality is only semi-supported. Range responses to the browser will work but the full content is fetched to BookStack, then partially streamed. Means it acts the same browser side, but not great for large video as you'll still be waiting for the full content. Could benefit in some minor cases though, especially where app hosted close to storage. Is possible to stream on s3-side, but can't seek, so would need a specific solution to range on that side also lower down in driver. Support for s3 services could vary there. Might also be better to use a signed url base approach depending on support. For now, this shouldn't have any added downsides, so we'll skip any added s3-specific complexity for now. ## Todo - [x] Add range header support - [x] Add support for head requests - [x] Test in a range of browsers - [x] Test content at boundaries - [x] Test with length just before sniff length - [x] Test with length just after sniff length - [x] Test with streaming from s3-like storage - [x] Cover with testing --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 10:31:23 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#6405