feat: add Content-Length headers to admin API responses (#169)

This commit is contained in:
weisd
2025-07-11 09:40:57 +08:00
committed by GitHub
parent b33c2fa3cf
commit be05b704b0
8 changed files with 47 additions and 21 deletions
+1
View File
@@ -596,6 +596,7 @@ impl Operation for ImportBucketMetadata {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
+5
View File
@@ -19,6 +19,7 @@ use matchit::Params;
use rustfs_config::notify::{NOTIFY_MQTT_SUB_SYS, NOTIFY_WEBHOOK_SUB_SYS}; use rustfs_config::notify::{NOTIFY_MQTT_SUB_SYS, NOTIFY_WEBHOOK_SUB_SYS};
use rustfs_notify::EventName; use rustfs_notify::EventName;
use rustfs_notify::rules::{BucketNotificationConfig, PatternRules}; use rustfs_notify::rules::{BucketNotificationConfig, PatternRules};
use s3s::header::CONTENT_LENGTH;
use s3s::{Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, header::CONTENT_TYPE, s3_error}; use s3s::{Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, header::CONTENT_TYPE, s3_error};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_urlencoded::from_bytes; use serde_urlencoded::from_bytes;
@@ -103,6 +104,7 @@ impl Operation for SetNotificationTarget {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -181,6 +183,7 @@ impl Operation for RemoveNotificationTarget {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -226,6 +229,7 @@ impl Operation for SetBucketNotification {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -289,6 +293,7 @@ impl Operation for RemoveBucketNotification {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
+7 -3
View File
@@ -17,7 +17,11 @@ use matchit::Params;
use rustfs_ecstore::global::get_global_action_cred; use rustfs_ecstore::global::get_global_action_cred;
use rustfs_iam::error::{is_err_no_such_group, is_err_no_such_user}; use rustfs_iam::error::{is_err_no_such_group, is_err_no_such_user};
use rustfs_madmin::GroupAddRemove; use rustfs_madmin::GroupAddRemove;
use s3s::{Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, header::CONTENT_TYPE, s3_error}; use s3s::{
Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result,
header::{CONTENT_LENGTH, CONTENT_TYPE},
s3_error,
};
use serde::Deserialize; use serde::Deserialize;
use serde_urlencoded::from_bytes; use serde_urlencoded::from_bytes;
use tracing::warn; use tracing::warn;
@@ -129,7 +133,7 @@ impl Operation for SetGroupStatus {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -214,7 +218,7 @@ impl Operation for UpdateGroupMembers {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
+8 -4
View File
@@ -19,7 +19,11 @@ use rustfs_ecstore::global::get_global_action_cred;
use rustfs_iam::error::is_err_no_such_user; use rustfs_iam::error::is_err_no_such_user;
use rustfs_iam::store::MappedPolicy; use rustfs_iam::store::MappedPolicy;
use rustfs_policy::policy::Policy; use rustfs_policy::policy::Policy;
use s3s::{Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, header::CONTENT_TYPE, s3_error}; use s3s::{
Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result,
header::{CONTENT_LENGTH, CONTENT_TYPE},
s3_error,
};
use serde::Deserialize; use serde::Deserialize;
use serde_urlencoded::from_bytes; use serde_urlencoded::from_bytes;
use std::collections::HashMap; use std::collections::HashMap;
@@ -123,7 +127,7 @@ impl Operation for AddCannedPolicy {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -198,7 +202,7 @@ impl Operation for RemoveCannedPolicy {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -284,7 +288,7 @@ impl Operation for SetPolicyForUserOrGroup {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
+9 -2
View File
@@ -22,7 +22,11 @@ use rustfs_ecstore::{
rebalance::{DiskStat, RebalSaveOpt}, rebalance::{DiskStat, RebalSaveOpt},
store_api::BucketOptions, store_api::BucketOptions,
}; };
use s3s::{Body, S3Request, S3Response, S3Result, header::CONTENT_TYPE, s3_error}; use s3s::{
Body, S3Request, S3Response, S3Result,
header::{CONTENT_LENGTH, CONTENT_TYPE},
s3_error,
};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::time::Duration; use std::time::Duration;
use time::OffsetDateTime; use time::OffsetDateTime;
@@ -265,7 +269,10 @@ impl Operation for RebalanceStop {
warn!("handle RebalanceStop notification_sys load_rebalance_meta done"); warn!("handle RebalanceStop notification_sys load_rebalance_meta done");
} }
Ok(S3Response::new((StatusCode::OK, Body::empty()))) let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
+3 -2
View File
@@ -28,6 +28,7 @@ use rustfs_madmin::{
use rustfs_policy::policy::action::{Action, AdminAction}; use rustfs_policy::policy::action::{Action, AdminAction};
use rustfs_policy::policy::{Args, Policy}; use rustfs_policy::policy::{Args, Policy};
use s3s::S3ErrorCode::InvalidRequest; use s3s::S3ErrorCode::InvalidRequest;
use s3s::header::CONTENT_LENGTH;
use s3s::{Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, header::CONTENT_TYPE, s3_error}; use s3s::{Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, header::CONTENT_TYPE, s3_error};
use serde::Deserialize; use serde::Deserialize;
use serde_urlencoded::from_bytes; use serde_urlencoded::from_bytes;
@@ -306,7 +307,7 @@ impl Operation for UpdateServiceAccount {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -607,7 +608,7 @@ impl Operation for DeleteServiceAccount {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
+11 -7
View File
@@ -16,7 +16,11 @@
use http::{HeaderMap, StatusCode}; use http::{HeaderMap, StatusCode};
//use iam::get_global_action_cred; //use iam::get_global_action_cred;
use matchit::Params; use matchit::Params;
use s3s::{Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, header::CONTENT_TYPE, s3_error}; use s3s::{
Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result,
header::{CONTENT_LENGTH, CONTENT_TYPE},
s3_error,
};
use serde_urlencoded::from_bytes; use serde_urlencoded::from_bytes;
use time::OffsetDateTime; use time::OffsetDateTime;
use tracing::{debug, warn}; use tracing::{debug, warn};
@@ -169,7 +173,7 @@ impl Operation for AddTier {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -236,7 +240,7 @@ impl Operation for EditTier {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -332,7 +336,7 @@ impl Operation for RemoveTier {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -366,7 +370,7 @@ impl Operation for VerifyTier {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -457,7 +461,7 @@ impl Operation for ClearTier {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -636,7 +640,7 @@ impl Operation for PostRestoreObject {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
}*/ }*/
+3 -3
View File
@@ -146,7 +146,7 @@ impl Operation for AddUser {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -193,7 +193,7 @@ impl Operation for SetUserStatus {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }
@@ -310,7 +310,7 @@ impl Operation for RemoveUser {
let mut header = HeaderMap::new(); let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap()); header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
header.insert(CONTENT_LENGTH, "0".parse().unwrap());
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header)) Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
} }
} }