Browse Source

Match Go ProcessRangeRequest: return full content for empty/oversized ranges

Go returns nil from ProcessRangeRequest when ranges are empty or total
range size exceeds content length, causing the caller to serve the full
content as a normal 200 response. Rust was returning an empty 200 body.
rust-volume-server
Chris Lu 3 days ago
parent
commit
f086e4b517
  1. 14
      seaweed-volume/src/server/handlers.rs

14
seaweed-volume/src/server/handlers.rs

@ -1411,12 +1411,20 @@ fn handle_range_request(
};
if ranges.is_empty() {
return (StatusCode::OK, headers).into_response();
headers.insert(
header::CONTENT_LENGTH,
data.len().to_string().parse().unwrap(),
);
return finalize_bytes_response(StatusCode::OK, headers, data.to_vec(), state);
}
// If combined range bytes exceed content size, ignore the range (return 200 empty)
// If combined range bytes exceed content size, ignore the range and return full data
if sum_ranges_size(&ranges) > total {
return (StatusCode::OK, headers).into_response();
headers.insert(
header::CONTENT_LENGTH,
data.len().to_string().parse().unwrap(),
);
return finalize_bytes_response(StatusCode::OK, headers, data.to_vec(), state);
}
if ranges.len() == 1 {

Loading…
Cancel
Save