Skip to content

Commit

Permalink
assets: Fix range request status code (#633)
Browse files Browse the repository at this point in the history
Should return partial content (206) rather than (200)
RFC 9110, section 14.2: "the server SHOULD send a 206 (Partial Content)
response with content containing one or more partial representations"

Signed-off-by: Janne Pelkonen <[email protected]>
  • Loading branch information
jpelkonen authored Oct 25, 2023
1 parent 7ea4025 commit 446279d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gotham/src/handler/assets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ fn create_file_response(options: FileOptions, state: State) -> Pin<Box<HandlerFu
(range_start + len).saturating_sub(1),
meta.len()
);
response = response.header(
response = response.status(StatusCode::PARTIAL_CONTENT).header(
CONTENT_RANGE,
HeaderValue::from_str(&val).map_err(|e| io::Error::new(ErrorKind::Other, e))?,
);
Expand Down Expand Up @@ -949,6 +949,7 @@ mod tests {
assert_eq!(response.status(), StatusCode::RANGE_NOT_SATISFIABLE);
break;
}
assert_eq!(response.status(), StatusCode::PARTIAL_CONTENT);
file.seek(SeekFrom::Start(range_start)).unwrap();

let expected_content_range = format!(
Expand Down

0 comments on commit 446279d

Please sign in to comment.