File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -461,19 +461,23 @@ function serve_file(
461
461
end
462
462
end
463
463
464
- range_match = match (r" bytes=(\d +)-(\d +) " , HTTP. header (req, " Range" , " " ))
464
+ range_match = match (r" ^ bytes=(\d +)-(\d *)$ " , HTTP. header (req, " Range" , " " ))
465
465
is_ranged = ! isnothing (range_match)
466
466
467
467
headers = [
468
468
" Content-Type" => content_type,
469
469
]
470
470
if is_ranged
471
- range = parse .(Int, range_match. captures)
471
+ p (s) = isempty (s) ? nothing : parse (Int64, s)
472
+ start, stop = p .(range_match. captures)
473
+ @assert start isa Int64 # because the regex requires at least one digit
474
+ stop = something (stop, binary_length (content) - 1 )
475
+
472
476
push! (headers,
473
477
" Content-Range" =>
474
- " bytes $(range[ 1 ] ) -$(range[ 2 ] ) /$(binary_length (content)) "
478
+ " bytes $(start ) -$(stop ) /$(binary_length (content)) "
475
479
)
476
- content = @view content[1 + range[ 1 ] : 1 + range[ 2 ] ]
480
+ content = @view content[1 + start : 1 + stop ]
477
481
ret_code = 206
478
482
end
479
483
if allow_cors
You can’t perform that action at this time.
0 commit comments