From 25fa5f3c2c7c1907183009a8c3e3b35e7d066500 Mon Sep 17 00:00:00 2001 From: Thomas Quinot Date: Wed, 5 Aug 2026 15:13:14 +0200 Subject: [PATCH] Fix WEBrick range requests for local video playback WEBrick's not_modified? treats a Range request's If-Range header like If-None-Match, replying 304 with no body instead of 206 with the requested bytes. Browsers rely on this to fetch a video's trailing moov atom, so jekyll serve was breaking playback for videos recorded with metadata at the end of the file. Dev-server-only; production is unaffected since it isn't served by WEBrick. Co-Authored-By: Claude Sonnet 5 --- _source/_plugins/webrick_range_fix.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 _source/_plugins/webrick_range_fix.rb diff --git a/_source/_plugins/webrick_range_fix.rb b/_source/_plugins/webrick_range_fix.rb new file mode 100644 index 0000000..e25dcda --- /dev/null +++ b/_source/_plugins/webrick_range_fix.rb @@ -0,0 +1,16 @@ +# Dev-server-only fix: WEBrick's FileHandler#not_modified? treats a Range +# request's If-Range header the same as If-None-Match, replying 304 (no body) +# instead of 206 with the requested bytes. Browsers rely on ranged requests +# (with If-Range) to fetch a video's trailing moov atom when seeking/loading +# metadata, so this breaks video playback under `jekyll serve`. +# See https://github.com/ruby/webrick/blob/master/lib/webrick/httpservlet/filehandler.rb +# +require 'webrick' + +module WebrickRangeFix + def not_modified?(req, res, mtime, etag) + req['Range'] ? false : super + end +end + +WEBrick::HTTPServlet::DefaultFileHandler.prepend(WebrickRangeFix)