mirror of
https://github.com/rustfs/rustfs.git
synced 2026-11-21 07:26:37 +00:00
refactor(admin): drop the legacy body limit arm
Owned handlers already pass the RustFS body. The over-limit, exact-limit, and transport-error checks stay on that body.
This commit is contained in:
@@ -49,8 +49,7 @@ pub(crate) async fn read_compatible_admin_body(
|
||||
path: &str,
|
||||
secret_key: &str,
|
||||
) -> S3Result<Vec<u8>> {
|
||||
// Legacy handlers still hand over the s3s body; owned handlers pass the
|
||||
// RustFS body. Both read through the owned type so one limit applies.
|
||||
// Callers pass an owned body. One length limit applies to every read.
|
||||
let mut input: rustfs_s3_types::Body = input.into();
|
||||
let body = input.store_all_limited(max_len).await.map_err(|e| {
|
||||
if e.is::<rustfs_s3_types::BodyTooLarge>() {
|
||||
@@ -242,13 +241,6 @@ mod tests {
|
||||
assert_eq!(err.code(), &S3ErrorCode::InvalidRequest);
|
||||
assert_eq!(err.message(), Some("failed to read request body: length limit exceeded"));
|
||||
|
||||
let legacy_body = s3s::Body::http_body(http_body_util::Full::new(bytes::Bytes::from_static(b"nine bytes!")));
|
||||
let legacy_err = read_compatible_admin_body(legacy_body, 8, "/rustfs/admin/v3/list-users", "secret")
|
||||
.await
|
||||
.expect_err("legacy streaming bodies retain the same limit error");
|
||||
assert_eq!(legacy_err.code(), err.code());
|
||||
assert_eq!(legacy_err.message(), err.message());
|
||||
|
||||
let exact =
|
||||
read_compatible_admin_body(rustfs_s3_types::Body::from("12345678"), 8, "/rustfs/admin/v3/list-users", "secret")
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user