Repository navigation
feat: warn when download handler does not answer range request - #26340
Conversation
In development mode, log a warning when a Source is given a download handler that does not answer byte range requests, since the player cannot seek in such a file and Safari does not play it.
Type of change
How to test
|
vaadin-review-bot
left a comment
There was a problem hiding this comment.
Reviewed the changes — left 1 comment.
| Finding | |
|---|---|
| For a lambda download handler the warning names a synthetic class, not anything the developer can act on. |
Warn from the handler that Source serves the media file through, the first time the browser requests a byte range that the handler does not answer. This reads isRangeRequestsEnabled() when it matters, keeps no global state and registers no attach listener.
Move the development-mode warning from Source to the request path of DownloadHandler, so that it covers every handler, logs once per handler class and application, and leaves Source serving the handler through allowDisabled() as before. The wrapper of allowDisabled() now delegates handleRequest, so an override of it in the wrapped handler is used.
Check the response after the handler has run, so a failed request or a handler that answers ranges itself is not warned about. Warn once per kind of handler so that the set of warned handlers stays bounded, and word the warning for any client that requests ranges.
Warn whenever a handler that does not answer byte ranges receives a range request, and word the warning as the whole file being served instead of the range.
Log the warning from the transfer of the built-in download handlers, right before they serve the whole content for a range request. It then appears before any byte is written, also when the client drops the connection, and not for a missing resource, an error response or a custom handler that answers ranges itself. Restore DownloadHandler and allowDisabled() to their previous behaviour.
Also warn when a built-in handler with ranges enabled serves the whole file because the content length is unknown or the response is not an HTTP servlet response, naming the cause and what to do about it.
Pass the handler type and served URL as logger arguments instead of concatenating them, and explain the empty handler in the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@sonarqubecloud Fixed all three in a new commit:
|
|
merge main |
…e-without-ranges # Conflicts: # flow-server/src/test/java/com/vaadin/flow/server/streams/AbstractDownloadHandlerTest.java
|
@Artur- Merged |
|
|
Documentation Bot: No documentation needed for this change. This is a Nothing was opened in vaadin/docs. If you disagree, the change has to be documented by hand there.
|
|
This ticket/PR has been released with Vaadin 25.4.0-alpha4. |



DX/docs · flow-server · apps that serve audio, video or large
downloads from a built-in
DownloadHandlerA built-in download handler that does not answer byte range requests
serves the whole file instead, so a media player cannot seek in it,
Safari does not play it, and a download cannot resume. Ranges are off
by default for every built-in handler except
forFile, and nothingtold the developer. Now a warning in development mode names the
handler and the ways to fix it.
Risks:
✅ No API change, no behaviour change; in production mode nothing is
logged, and the check is one header lookup per transfer without
ranges
The built-in handlers now log a development-mode warning when they
are about to serve the whole content for a request with a
Rangeheader, naming the cause and what to do about it: ranges are not
enabled, the content length is unknown, or the response is not an
HTTP servlet response
the player drops the connection
return before any transfer, nor for custom handlers, which may
answer ranges themselves
file and saying that other files served the same way are affected
too; tracked by class name in an attribute of the
VaadinContext