2020-08-22 02:35:32 +00:00
|
|
|
package api
|
|
|
|
|
2023-06-02 07:44:25 +00:00
|
|
|
import "net/http"
|
|
|
|
|
2021-06-30 15:10:11 +00:00
|
|
|
// Standard S3 HTTP request/response constants.
|
2020-08-22 02:35:32 +00:00
|
|
|
const (
|
2022-12-20 08:38:58 +00:00
|
|
|
MetadataPrefix = "X-Amz-Meta-"
|
|
|
|
FrostFSSystemMetadataPrefix = "S3-"
|
|
|
|
AmzMetadataDirective = "X-Amz-Metadata-Directive"
|
|
|
|
AmzTaggingDirective = "X-Amz-Tagging-Directive"
|
|
|
|
AmzVersionID = "X-Amz-Version-Id"
|
|
|
|
AmzTaggingCount = "X-Amz-Tagging-Count"
|
|
|
|
AmzTagging = "X-Amz-Tagging"
|
|
|
|
AmzDeleteMarker = "X-Amz-Delete-Marker"
|
|
|
|
AmzCopySource = "X-Amz-Copy-Source"
|
|
|
|
AmzCopySourceRange = "X-Amz-Copy-Source-Range"
|
|
|
|
AmzDate = "X-Amz-Date"
|
2021-07-07 14:52:36 +00:00
|
|
|
|
2020-08-22 02:35:32 +00:00
|
|
|
LastModified = "Last-Modified"
|
|
|
|
Date = "Date"
|
|
|
|
ETag = "ETag"
|
|
|
|
ContentType = "Content-Type"
|
|
|
|
ContentMD5 = "Content-Md5"
|
|
|
|
ContentEncoding = "Content-Encoding"
|
|
|
|
Expires = "Expires"
|
|
|
|
ContentLength = "Content-Length"
|
|
|
|
ContentLanguage = "Content-Language"
|
|
|
|
ContentRange = "Content-Range"
|
|
|
|
Connection = "Connection"
|
|
|
|
AcceptRanges = "Accept-Ranges"
|
|
|
|
AmzBucketRegion = "X-Amz-Bucket-Region"
|
|
|
|
ServerInfo = "Server"
|
|
|
|
RetryAfter = "Retry-After"
|
|
|
|
Location = "Location"
|
|
|
|
CacheControl = "Cache-Control"
|
|
|
|
ContentDisposition = "Content-Disposition"
|
|
|
|
Authorization = "Authorization"
|
|
|
|
Action = "Action"
|
2021-06-30 15:10:11 +00:00
|
|
|
IfModifiedSince = "If-Modified-Since"
|
|
|
|
IfUnmodifiedSince = "If-Unmodified-Since"
|
2021-07-02 16:05:43 +00:00
|
|
|
IfMatch = "If-Match"
|
|
|
|
IfNoneMatch = "If-None-Match"
|
2021-07-01 07:45:55 +00:00
|
|
|
|
2023-06-02 07:44:25 +00:00
|
|
|
AmzContentSha256 = "X-Amz-Content-Sha256"
|
2021-08-23 08:19:41 +00:00
|
|
|
AmzCopyIfModifiedSince = "X-Amz-Copy-Source-If-Modified-Since"
|
|
|
|
AmzCopyIfUnmodifiedSince = "X-Amz-Copy-Source-If-Unmodified-Since"
|
|
|
|
AmzCopyIfMatch = "X-Amz-Copy-Source-If-Match"
|
|
|
|
AmzCopyIfNoneMatch = "X-Amz-Copy-Source-If-None-Match"
|
|
|
|
AmzACL = "X-Amz-Acl"
|
2023-06-02 07:44:25 +00:00
|
|
|
AmzDecodedContentLength = "X-Amz-Decoded-Content-Length"
|
2021-08-23 08:19:41 +00:00
|
|
|
AmzGrantFullControl = "X-Amz-Grant-Full-Control"
|
|
|
|
AmzGrantRead = "X-Amz-Grant-Read"
|
|
|
|
AmzGrantWrite = "X-Amz-Grant-Write"
|
|
|
|
AmzExpectedBucketOwner = "X-Amz-Expected-Bucket-Owner"
|
|
|
|
AmzSourceExpectedBucketOwner = "X-Amz-Source-Expected-Bucket-Owner"
|
2022-02-25 09:06:40 +00:00
|
|
|
AmzBucketObjectLockEnabled = "X-Amz-Bucket-Object-Lock-Enabled"
|
2022-02-28 10:22:07 +00:00
|
|
|
AmzObjectLockLegalHold = "X-Amz-Object-Lock-Legal-Hold"
|
|
|
|
AmzObjectLockMode = "X-Amz-Object-Lock-Mode"
|
|
|
|
AmzObjectLockRetainUntilDate = "X-Amz-Object-Lock-Retain-Until-Date"
|
2022-02-28 13:39:04 +00:00
|
|
|
AmzBypassGovernanceRetention = "X-Amz-Bypass-Governance-Retention"
|
2022-06-01 09:54:27 +00:00
|
|
|
AmzObjectAttributes = "X-Amz-Object-Attributes"
|
2022-06-02 15:26:26 +00:00
|
|
|
AmzMaxParts = "X-Amz-Max-Parts"
|
|
|
|
AmzPartNumberMarker = "X-Amz-Part-Number-Marker"
|
2023-10-25 11:49:39 +00:00
|
|
|
AmzStorageClass = "X-Amz-Storage-Class"
|
2024-07-19 19:20:40 +00:00
|
|
|
AmzForceBucketDelete = "X-Amz-Force-Delete-Bucket"
|
2021-08-23 08:37:08 +00:00
|
|
|
|
2022-08-01 16:52:09 +00:00
|
|
|
AmzServerSideEncryptionCustomerAlgorithm = "x-amz-server-side-encryption-customer-algorithm"
|
|
|
|
AmzServerSideEncryptionCustomerKey = "x-amz-server-side-encryption-customer-key"
|
|
|
|
AmzServerSideEncryptionCustomerKeyMD5 = "x-amz-server-side-encryption-customer-key-MD5"
|
|
|
|
|
2023-10-19 14:22:26 +00:00
|
|
|
AmzCopySourceServerSideEncryptionCustomerAlgorithm = "x-amz-copy-source-server-side-encryption-customer-algorithm"
|
|
|
|
AmzCopySourceServerSideEncryptionCustomerKey = "x-amz-copy-source-server-side-encryption-customer-key"
|
|
|
|
AmzCopySourceServerSideEncryptionCustomerKeyMD5 = "x-amz-copy-source-server-side-encryption-customer-key-MD5"
|
|
|
|
|
2023-04-14 13:46:51 +00:00
|
|
|
OwnerID = "X-Owner-Id"
|
2023-01-30 16:44:28 +00:00
|
|
|
ContainerID = "X-Container-Id"
|
|
|
|
ContainerName = "X-Container-Name"
|
2023-02-10 12:19:29 +00:00
|
|
|
ContainerZone = "X-Container-Zone"
|
2021-10-04 14:32:35 +00:00
|
|
|
|
|
|
|
AccessControlAllowOrigin = "Access-Control-Allow-Origin"
|
|
|
|
AccessControlAllowMethods = "Access-Control-Allow-Methods"
|
|
|
|
AccessControlExposeHeaders = "Access-Control-Expose-Headers"
|
|
|
|
AccessControlAllowHeaders = "Access-Control-Allow-Headers"
|
|
|
|
AccessControlMaxAge = "Access-Control-Max-Age"
|
|
|
|
AccessControlAllowCredentials = "Access-Control-Allow-Credentials"
|
|
|
|
|
|
|
|
Origin = "Origin"
|
|
|
|
AccessControlRequestMethod = "Access-Control-Request-Method"
|
|
|
|
AccessControlRequestHeaders = "Access-Control-Request-Headers"
|
|
|
|
|
2023-06-02 07:44:25 +00:00
|
|
|
AwsChunked = "aws-chunked"
|
|
|
|
|
2021-10-04 14:32:35 +00:00
|
|
|
Vary = "Vary"
|
2022-05-30 11:33:46 +00:00
|
|
|
|
|
|
|
DefaultLocationConstraint = "default"
|
2023-06-02 07:44:25 +00:00
|
|
|
|
2024-03-27 06:14:58 +00:00
|
|
|
StreamingContentSHA256 = "STREAMING-AWS4-HMAC-SHA256-PAYLOAD"
|
|
|
|
StreamingContentV4aSHA256 = "STREAMING-AWS4-ECDSA-P256-SHA256-PAYLOAD"
|
2023-10-25 11:49:39 +00:00
|
|
|
|
|
|
|
DefaultStorageClass = "STANDARD"
|
2020-08-22 02:35:32 +00:00
|
|
|
)
|
2021-08-19 06:55:22 +00:00
|
|
|
|
|
|
|
// S3 request query params.
|
|
|
|
const (
|
|
|
|
QueryVersionID = "versionId"
|
|
|
|
)
|
2022-01-21 09:52:16 +00:00
|
|
|
|
|
|
|
// ResponseModifiers maps response modifies headers to regular headers.
|
|
|
|
var ResponseModifiers = map[string]string{
|
|
|
|
"response-content-type": ContentType,
|
|
|
|
"response-content-language": ContentLanguage,
|
|
|
|
"response-expires": Expires,
|
|
|
|
"response-cache-control": CacheControl,
|
|
|
|
"response-content-disposition": ContentDisposition,
|
|
|
|
"response-content-encoding": ContentEncoding,
|
|
|
|
}
|
2022-07-26 01:08:25 +00:00
|
|
|
|
|
|
|
var SystemMetadata = map[string]struct{}{
|
|
|
|
Date: {},
|
|
|
|
CacheControl: {},
|
|
|
|
ContentDisposition: {},
|
|
|
|
ContentLength: {},
|
|
|
|
ContentType: {},
|
|
|
|
LastModified: {},
|
|
|
|
ETag: {},
|
2023-10-16 15:32:08 +00:00
|
|
|
ContentLanguage: {},
|
2022-07-26 01:08:25 +00:00
|
|
|
}
|
2023-06-02 07:44:25 +00:00
|
|
|
|
2024-03-27 06:14:58 +00:00
|
|
|
func IsSignedStreamingV4(r *http.Request) (string, bool) {
|
|
|
|
shaHeader := r.Header.Get(AmzContentSha256)
|
|
|
|
return shaHeader,
|
|
|
|
(shaHeader == StreamingContentSHA256 || shaHeader == StreamingContentV4aSHA256) &&
|
|
|
|
r.Method == http.MethodPut
|
2023-06-02 07:44:25 +00:00
|
|
|
}
|