fix(gateway): restore the gateway-stack build after the rename-batch merge

The squash of #9489 carried two hunks of an unlanded POST change that call
post_effective_headers, which main does not define, so every build with the
gateway-stack feature failed. Read the request headers as before; the POST
change reapplies cleanly on top. Also drops trailing whitespace that fails
cargo fmt --check.
This commit is contained in:
overtrue
2026-11-18 20:41:23 +08:00
parent 447f18db43
commit 142cff57a3
3 changed files with 8 additions and 18 deletions
@@ -866,7 +866,7 @@ mod tests {
.authorization
.oidc_virtual_parent()
.expect("test authorization should have a virtual parent");
// Virtual parent IDs cannot be registered as users, but a legacy mapping can still exist.
iam.policy_db_set(&parent, UserType::Reg, false, "readonly")
.await
@@ -74,14 +74,13 @@ impl PreflightedPostArchive {
let identity = envelope
.gateway_post_identity()
.ok_or_else(|| s3_error!(AccessDenied, "The POST archive request identity is missing"))?;
let effective_headers = super::super::post_headers::post_effective_headers(envelope);
let options = super::super::extract::resolve_put_object_extract_options(effective_headers)
let options = super::super::extract::resolve_put_object_extract_options(envelope.headers())
.map_err(rustfs_s3_types::S3Error::from)?;
if !Arc::ptr_eq(identity, &self.request_identity)
|| bucket != self.bucket
|| key != self.key
|| options != self.options
|| !super::super::extract::is_put_object_extract_requested(effective_headers)
|| !super::super::extract::is_put_object_extract_requested(envelope.headers())
{
return Err(s3_error!(AccessDenied, "The POST archive does not match its preflight"));
}
@@ -118,8 +117,7 @@ async fn stage_post_archive_with_resources(
policy: VerifiedPostArchivePolicy,
resources: &StagingResources,
) -> S3Result<PreflightedPostArchive> {
let effective_headers = super::super::post_headers::post_effective_headers(envelope);
if bucket != policy.bucket || key != policy.key || !super::super::extract::is_put_object_extract_requested(effective_headers)
if bucket != policy.bucket || key != policy.key || !super::super::extract::is_put_object_extract_requested(envelope.headers())
{
return Err(s3_error!(AccessDenied, "The POST archive does not match its verified policy"));
}
@@ -129,7 +127,7 @@ async fn stage_post_archive_with_resources(
.ok_or_else(|| s3_error!(AccessDenied, "The POST archive request identity is missing"))?,
);
let options =
super::super::extract::resolve_put_object_extract_options(effective_headers).map_err(rustfs_s3_types::S3Error::from)?;
super::super::extract::resolve_put_object_extract_options(envelope.headers()).map_err(rustfs_s3_types::S3Error::from)?;
if resources.archive_snapshot_budget.is_closed() {
return Err(staging_capacity_error());
}
@@ -148,7 +146,7 @@ async fn stage_post_archive_with_resources(
let replay_length = u64::try_from(length).map_err(|_| staging_io_error())?;
let snapshot = ArchiveSnapshot::capture(file, replay_length, Arc::clone(&resources.archive_snapshot_budget)).await?;
let snapshot = snapshot
.preflight(&policy.key, effective_headers, policy.permits.as_ref())
.preflight(&policy.key, envelope.headers(), policy.permits.as_ref())
.await?;
Ok(PreflightedPostArchive {
snapshot,
+2 -10
View File
@@ -1238,22 +1238,14 @@ impl DefaultObjectUsecase {
// historical user metadata as a request to untar the member again.
let inbound_replication_put = replication_request_authorized(&envelope)
&& get_header(envelope.headers(), SUFFIX_SOURCE_REPLICATION_REQUEST).as_deref() == Some("true");
#[cfg(feature = "gateway-stack")]
let extract_headers = if envelope.is_gateway_post() {
super::post_headers::post_effective_headers(&envelope)
} else {
envelope.headers()
};
#[cfg(not(feature = "gateway-stack"))]
let extract_headers = envelope.headers();
if max_content_length.is_some() && is_put_object_extract_requested(extract_headers) {
if max_content_length.is_some() && is_put_object_extract_requested(envelope.headers()) {
return Err(S3Error::with_message(
S3ErrorCode::InvalidRequest,
format!("{RUSTFS_MAX_CONTENT_LENGTH_QUERY} is not supported for archive extraction"),
));
}
reject_veeam_sosapi_mutation(|| self.object_store(), input.bucket.as_str(), input.key.as_str()).await?;
if is_put_object_extract_requested(extract_headers) && !inbound_replication_put {
if is_put_object_extract_requested(envelope.headers()) && !inbound_replication_put {
return Box::pin(self.execute_put_object_extract_owned(envelope, input)).await;
}
// SSE-C ciphertext passthrough (authorized replication only): the body