bucketwarden-server 0.1.0

BucketWarden storage server runtime.
Documentation
pub(crate) fn apply_checksum_response_headers(
    mut response: S3HttpResponse,
    checksums: ValidatedWriteChecksums,
) -> S3HttpResponse {
    if let Some(value) = checksums.content_md5 {
        response.headers.insert("content-md5".to_string(), value);
    }
    if let Some(value) = checksums.checksum_sha256 {
        response
            .headers
            .insert("x-amz-checksum-sha256".to_string(), value);
    }
    response
}

pub(crate) fn apply_encryption_response_headers(
    mut response: S3HttpResponse,
    encryption: Option<&ServerSideEncryption>,
) -> S3HttpResponse {
    if let Some(encryption) = encryption {
        response.headers.insert(
            "x-amz-server-side-encryption".to_string(),
            encryption.algorithm.clone(),
        );
        if let Some(kms_key_id) = &encryption.kms_key_id {
            response.headers.insert(
                "x-amz-server-side-encryption-aws-kms-key-id".to_string(),
                kms_key_id.clone(),
            );
        }
    }
    response
}

pub(crate) fn apply_response_header_overrides(
    mut response: S3HttpResponse,
    query: &BTreeMap<String, String>,
) -> S3HttpResponse {
    for (query_key, header_name) in [
        ("response-cache-control", "cache-control"),
        ("response-content-disposition", "content-disposition"),
        ("response-content-encoding", "content-encoding"),
        ("response-content-language", "content-language"),
        ("response-content-type", "content-type"),
        ("response-expires", "expires"),
    ] {
        if let Some(value) = query.get(query_key) {
            response.headers.insert(header_name.to_string(), value.clone());
        }
    }
    response
}

pub(crate) fn apply_replication_status_header(
    mut response: S3HttpResponse,
    status: Option<&str>,
) -> S3HttpResponse {
    if let Some(status) = status {
        response
            .headers
            .insert("x-amz-replication-status".to_string(), status.to_string());
    }
    response
}