You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ServeDir/ServeFile validate multipart Range requests before rejecting them with 416 #660
ServeDir / ServeFile do not support multipart range responses, but they still parse and validate multipart Range headers before later rejecting them with 416 Range Not Satisfiable.
later, future.rs::build_response() rejects ranges.len() > 1 with 416
So a request like:
Range: bytes=0-0,2-2,4-4,6-6
is guaranteed to be rejected, but still pays multipart validation cost first, with the validation step doing O(n²) pairwise overlap checks across ranges.
Since multipart responses are not supported here, it seems better to reject ranges.len() > 1 before calling validate(file_size).
A minimal fix seems to be:
parse the header
if there is more than one range, immediately return unsatisfiable
only call validate(file_size) for single-range requests
changed the title [-]ServeDir/ServeFile do unnecessary multipart Range validation before returning 416[/-][+]ServeDir/ServeFile validate multipart Range requests before rejecting them with 416[/+]on Apr 20, 2026
Activity
[-]ServeDir/ServeFile do unnecessary multipart Range validation before returning 416[/-][+]ServeDir/ServeFile validate multipart Range requests before rejecting them with 416[/+]seanmonstar commentedon Apr 20, 2026
It sounds reasonable to return an error after noticing a second range. Want to submit a PR?
shblue21 commentedon Apr 20, 2026
Sure, I can send a PR.
jlizen commentedon Aug 16, 2026
fixed by #661