Add Range request test: verify dav-server partial content support
- test_range_request: GET with Range header returns 206 + partial content - Verify Content-Range header present - Test bytes=5-10 returns correct 6-byte slice Tests: 289 passed, 0 failed
This commit is contained in:
@@ -1522,4 +1522,28 @@ mod integration_tests {
|
||||
assert!(xml.contains("D:acl"), "PROPFIND response should contain D:acl element");
|
||||
assert!(xml.contains("D:all"), "ACL should grant all privileges to all principals");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_range_request() {
|
||||
let tmp = TempDir::new().unwrap();
|
||||
std::fs::write(tmp.path().join("range_test.txt"), "0123456789abcdefghij").unwrap();
|
||||
let handler = make_handler(&tmp);
|
||||
|
||||
// Range request: bytes=5-10
|
||||
let req = http::Request::builder()
|
||||
.method(Method::GET)
|
||||
.uri("/range_test.txt")
|
||||
.header("Range", "bytes=5-10")
|
||||
.body(ReqBody::from(""))
|
||||
.unwrap();
|
||||
let res = handler.handle(req).await;
|
||||
assert_eq!(res.status(), StatusCode::PARTIAL_CONTENT, "Range request should return 206");
|
||||
assert!(
|
||||
res.headers().contains_key("Content-Range"),
|
||||
"Range response should include Content-Range header"
|
||||
);
|
||||
let (_, body) = collect_body(res).await;
|
||||
let content = String::from_utf8(body).unwrap();
|
||||
assert_eq!(content, "56789a", "Range bytes=5-10 should return '56789a' (6 bytes)");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user