Documentation
¶
Overview ¶
code modified from golang std library src/internal/filepathlite/path.go to support path separator '/' for all platforms.
Index ¶
- Constants
- func AddCRCChecksum(algo types.ChecksumAlgorithm, crc, partCrc string, partLen int64) (string, error)
- func ApplyOverride(original, override *string) *string
- func Base64SumString(b []byte) string
- func CheckPresignedSignature(ctx fiber.Ctx, auth AuthData, derivedKey []byte) error
- func CheckValidSignature(ctx fiber.Ctx, auth AuthData, derivedKey []byte, checksum string, ...) (string, error)
- func ConvertPtrToStringPtr[T any](val *T) *string
- func ConvertTaggingXMLToQueryString(data []byte) (string, error)
- func ConvertToStringPtr[T any](val T) *string
- func DetectResourceType(ctx fiber.Ctx) s3err.ResourceType
- func EnsureRequestIDs(ctx fiber.Ctx) (requestID, hostID string)
- func ExtractChecksumType(ctx fiber.Ctx) (checksumType, error)
- func ExtractMetadataFromFields(fields map[string]string) (map[string]string, error)
- func FilterObjectAttributes(attrs map[s3response.ObjectAttributes]struct{}, ...) s3response.GetObjectAttributesResponse
- func FormatDatePtrToString(date *time.Time, format string) *string
- func FormatRetainUntilDate(date *time.Time) *string
- func FromSlash(path string) string
- func GenerateObjectLocation(ctx fiber.Ctx, virtualDomain, bucket, object string) string
- func GetInt64(n *int64) int64
- func GetQueryParam(ctx fiber.Ctx, key string) *string
- func GetStringPtr(str string) *string
- func GetUserMetaData(headers *fasthttp.RequestHeader) (map[string]string, error)
- func HasAwsChunkedEncoding(contentEncoding string) bool
- func HasPayloadIntegrityCheck(ctx fiber.Ctx) bool
- func HexBytes(s string) string
- func HostID(ctx fiber.Ctx) string
- func IsAnonymousPayloadHashSupported(hash string) error
- func IsChecksumAlgorithmValid(alg types.ChecksumAlgorithm) error
- func IsChecksumComposable(algo types.ChecksumAlgorithm) bool
- func IsChecksumTypeValid(t types.ChecksumType) error
- func IsObjectNameValid(name string) bool
- func IsPresignedURLAuth(ctx fiber.Ctx) bool
- func IsPresignedURLAuthV2(ctx fiber.Ctx) bool
- func IsSpecialPayload(str string) bool
- func IsStreamingPayload(str string) bool
- func IsUnsignedPaylod(hash string) bool
- func IsUnsignedStreamingPayload(str string) bool
- func IsValidBucketName(bucket string) bool
- func IsValidChecksum(checksum string, algorithm types.ChecksumAlgorithm) bool
- func IsValidOwnership(val types.ObjectOwnership) bool
- func IsValidSha256PayloadHeader(value string) bool
- func MergeDeleteObjectsResult(objects []types.ObjectIdentifier, checkErrs []error, ...) s3response.DeleteResult
- func NewChunkReader(ctx fiber.Ctx, r io.Reader, authdata AuthData, canonicalString string, ...) (io.Reader, error)
- func NewHash(ht HashType) (hash.Hash, error)
- func NewS3HostID() string
- func NewS3RequestID() string
- func NewSignedChunkReader(r io.Reader, authdata AuthData, canonicalString string, derivedKey []byte, ...) (io.Reader, error)
- func NewTLSListener(network string, address string, ...) (net.Listener, error)
- func ParsObjectLockHdrs(ctx fiber.Ctx) (*objLockCfg, error)
- func ParseContentEncoding(ctx fiber.Ctx) string
- func ParseCreateMpChecksumHeaders(ctx fiber.Ctx) (types.ChecksumAlgorithm, types.ChecksumType, error)
- func ParseDecodedContentLength(ctx fiber.Ctx) (int64, error)
- func ParseDeleteObjects(objs []types.ObjectIdentifier) (result []string)
- func ParseIfMatchSize(ctx fiber.Ctx) *int64
- func ParseMaxLimiter(limiter string, lt LimiterType) (int32, error)
- func ParseObjectAttributes(ctx fiber.Ctx) (map[s3response.ObjectAttributes]struct{}, error)
- func ParseObjectLockFields(fields map[string]string) (*objLockCfg, error)
- func ParsePreconditionDateHeader(date string) *time.Time
- func ParsePreconditionDateHeaders(ctx fiber.Ctx, opts ...preconditionOpt) (*time.Time, *time.Time)
- func ParsePreconditionMatchHeaders(ctx fiber.Ctx, opts ...preconditionOpt) (*string, *string)
- func ParseTagging(data []byte, limit TagLimit) (map[string]string, error)
- func RequestID(ctx fiber.Ctx) string
- func SetBucketNameValidationStrict(strict bool)
- func SetMetaHeaders(ctx fiber.Ctx, meta map[string]string)
- func SetRegionMismatchHeader(ctx fiber.Ctx, err error)
- func SetResponseHeaders(ctx fiber.Ctx, headers []CustomHeader)
- func SignPostPolicy(base64Policy string, derivedKey []byte) (string, error)
- func StreamResponseBody(ctx fiber.Ctx, rdr io.ReadCloser, bodysize int)
- func TrimQuotes(str string) string
- func ValidateBucketRegion(bucketRegion, region string) error
- func ValidateCopySource(input string) error
- func ValidateDate(date time.Time) error
- func ValidateLocationConstraint(constraint *string, region string) error
- func ValidateSSEHeaders(ssec SSECHeaders, serverSideEncryption string) error
- func ValidateVersionId(ctx fiber.Ctx) error
- func ValidateWebsiteRedirectLocation(location string) error
- func WithCopySource() preconditionOpt
- type AuthData
- type ChecksumValues
- func ParseCalculatedChecksumFields(fields map[string]string) (ChecksumValues, error)
- func ParseCalculatedChecksumHeaders(ctx fiber.Ctx) (ChecksumValues, error)
- func ParseChecksumHeadersAndSdkAlgo(ctx fiber.Ctx) (types.ChecksumAlgorithm, ChecksumValues, error)
- func ParseCompleteMpChecksumHeaders(ctx fiber.Ctx) (ChecksumValues, error)
- type ChunkReader
- type CompositeChecksumReader
- type ConditionalHeaders
- type ContentLengthReader
- type ContextKey
- type CredentialsScope
- type CredsError
- type CustomHeader
- type HashReader
- type HashType
- type LimiterType
- type MpFileReader
- type MpParseResult
- type MultipartParser
- type SSECHeaders
- type TagLimit
- type UnsignedChunkReader
Constants ¶
const ( ContextKeyRegion = httpctx.ContextKeyRegion ContextKeyStartTime = httpctx.ContextKeyStartTime ContextKeyIsRoot = httpctx.ContextKeyIsRoot ContextKeyRootAccessKey = httpctx.ContextKeyRootAccessKey ContextKeyAccount = httpctx.ContextKeyAccount ContextKeyAuthenticated = httpctx.ContextKeyAuthenticated ContextKeyPublicBucket = httpctx.ContextKeyPublicBucket ContextKeyParsedAcl = httpctx.ContextKeyParsedAcl ContextKeySkipResBodyLog = httpctx.ContextKeySkipResBodyLog ContextKeyBodyReader = httpctx.ContextKeyBodyReader ContextKeyBodyStream = httpctx.ContextKeyBodyStream ContextKeySkip = httpctx.ContextKeySkip ContextKeyStack = httpctx.ContextKeyStack ContextKeyBucketOwner = httpctx.ContextKeyBucketOwner ContextKeyObjectPostResult = httpctx.ContextKeyObjectPostResult ContextKeyRequestID = httpctx.ContextKeyRequestID ContextKeyHostID = httpctx.ContextKeyHostID ContextKeyWebsiteConfig = httpctx.ContextKeyWebsiteConfig )
const ( HeaderAmzRequestID = "x-amz-request-id" HeaderAmzID2 = "x-amz-id-2" )
const ( // Standard S3 limiters LimiterTypeMaxKeys = "max-keys" // ListObjects, ListObjectVersions LimiterTypeMaxParts = "max-parts" // ListParts LimiterTypeMaxUploads = "max-uploads" // ListMultipartUploads LimiterTypePartNumberMarker = "part-number-marker" // ListParts(partNumberMarker) LimiterTypeVersionsMaxKeys = "versions_max_keys" // ListObjectVersions (internal alias mapped to max-keys) LimiterTypeMaxBuckets = "max-buckets" // ListBuckets )
const AwsChunkedEncoding = "aws-chunked"
AwsChunkedEncoding is the coding a client announces when it frames a body in aws-chunked, as the SDKs do to carry a trailing checksum.
Variables ¶
This section is empty.
Functions ¶
func AddCRCChecksum ¶ added in v1.0.15
func AddCRCChecksum(algo types.ChecksumAlgorithm, crc, partCrc string, partLen int64) (string, error)
AddCRCChecksum calculates the composite CRC checksum after adding the part crc. Only CRC32, CRC32C, and CRC64NVME are supported. The input checksums must be base64-encoded strings.
func ApplyOverride ¶ added in v1.0.18
ApplyOverride returns the override value if it exists and status is 200, otherwise returns original
func Base64SumString ¶ added in v1.0.11
Base64SumString converts the hash bytes to the b64 encoded string checksum value
func CheckPresignedSignature ¶
CheckPresignedSignature validates a presigned request's signature against derivedKey
func CheckValidSignature ¶
func CheckValidSignature(ctx fiber.Ctx, auth AuthData, derivedKey []byte, checksum string, tdate time.Time, contentLen int64) (string, error)
CheckValidSignature validates the ctx v4 auth signature against derivedKey — the request's kSigning value, either derived locally from a known secret or obtained from a standalone IAM service that never reveals the secret itself.
func ConvertPtrToStringPtr ¶ added in v1.0.17
Converts any pointer to a string pointer
func ConvertTaggingXMLToQueryString ¶ added in v1.4.0
ConvertTaggingXMLToQueryString parses object tagging XML and converts it into the x-amz-tagging query-string form expected by PutObject requests.
func ConvertToStringPtr ¶ added in v1.0.17
Converts any type to a string pointer
func DetectResourceType ¶ added in v1.5.0
func DetectResourceType(ctx fiber.Ctx) s3err.ResourceType
func EnsureRequestIDs ¶ added in v1.5.0
EnsureRequestIDs makes sure the request-local IDs exist and are present in the response headers. Existing local values are reused so headers and XML bodies stay consistent throughout the request.
func ExtractChecksumType ¶ added in v1.0.15
Extracts and validates the checksum type from the 'X-Amz-Trailer' header
func ExtractMetadataFromFields ¶ added in v1.4.0
func FilterObjectAttributes ¶
func FilterObjectAttributes(attrs map[s3response.ObjectAttributes]struct{}, output s3response.GetObjectAttributesResponse) s3response.GetObjectAttributesResponse
func FormatDatePtrToString ¶ added in v1.0.17
Formats the date with the given formatting and returns a string pointer
func FormatRetainUntilDate ¶ added in v1.9.0
FormatRetainUntilDate formats an Object Lock retain until date for a response header: in UTC to the millisecond, with the milliseconds left out when they are zero.
func GenerateObjectLocation ¶ added in v1.1.0
GenerateObjectLocation generates the object location path-styled or host-styled depending on the gateway configuration
func GetQueryParam ¶ added in v1.0.18
GetQueryParam returns a pointer to the query parameter value if it exists
func GetStringPtr ¶ added in v1.0.17
Returns the provided string pointer
func GetUserMetaData ¶
func GetUserMetaData(headers *fasthttp.RequestHeader) (map[string]string, error)
GetUserMetaData extracts user metadata from headers with the "x-amz-meta-" prefix. Keys are normalized to lowercase and duplicate headers are merged as comma-separated values. The total metadata size is validated against the 2 KB S3 limit.
func HasAwsChunkedEncoding ¶ added in v1.9.0
HasAwsChunkedEncoding reports whether a Content-Encoding value carries the aws-chunked token.
func HasPayloadIntegrityCheck ¶ added in v1.9.0
HasPayloadIntegrityCheck reports whether an upload carries an integrity check of its body: a Content-MD5 header, an x-amz-checksum-* header, or an x-amz-checksum-* trailer. A payload hash, signed or not, and chunk signatures don't count as one.
func IsAnonymousPayloadHashSupported ¶ added in v1.0.19
IsAnonymousPayloadHashSupported returns error if payload hash is streaming signed. e.g. "STREAMING-AWS4-HMAC-SHA256-PAYLOAD", "STREAMING-AWS4-ECDSA-P256-SHA256-PAYLOAD" ...
func IsChecksumAlgorithmValid ¶ added in v1.0.11
func IsChecksumAlgorithmValid(alg types.ChecksumAlgorithm) error
func IsChecksumComposable ¶ added in v1.0.15
func IsChecksumComposable(algo types.ChecksumAlgorithm) bool
IsChecksumComposable tests if the final full-object crc can be calculated from the part crc values.
func IsChecksumTypeValid ¶ added in v1.0.11
func IsChecksumTypeValid(t types.ChecksumType) error
Validates the provided checksum type
func IsObjectNameValid ¶ added in v1.0.15
func IsPresignedURLAuth ¶ added in v1.0.19
IsPresignedURLAuth determines if the request is presigned: which is authorization with query params
func IsPresignedURLAuthV2 ¶ added in v1.5.0
IsPresignedURLAuthV2 determines if the request is query-string signed with aws v2 signer
func IsSpecialPayload ¶
IsSpecialPayload checks for special authorization types
func IsStreamingPayload ¶ added in v1.0.11
IsStreamingPayload checks for streaming/unsigned authorization types
func IsUnsignedPaylod ¶ added in v1.0.19
IsUnsignedPaylod checks if the provided payload hash type is "UNSIGNED-PAYLOAD"
func IsUnsignedStreamingPayload ¶ added in v1.0.15
Checks if the provided string is unsigned payload trailer type
func IsValidBucketName ¶
func IsValidChecksum ¶ added in v1.0.11
func IsValidChecksum(checksum string, algorithm types.ChecksumAlgorithm) bool
func IsValidOwnership ¶ added in v1.0.3
func IsValidOwnership(val types.ObjectOwnership) bool
func IsValidSha256PayloadHeader ¶ added in v1.5.0
IsValidSha256PayloadHeader checks if the provided x-amz-content-sha256 payload header is valid special payload type or a valid sh256 hash
func MergeDeleteObjectsResult ¶ added in v1.8.0
func MergeDeleteObjectsResult(objects []types.ObjectIdentifier, checkErrs []error, backendResult s3response.DeleteResult) s3response.DeleteResult
MergeDeleteObjectsResult builds the final DeleteObjects response, preserving the order objects were requested in across both the Deleted and Error lists. objects is the full request; checkErrs is VerifyObjectsAccess's per-object result for it (nil entries were sent to the backend); backendResult is the backend's response for just those.
The backend's own Deleted/Error order is not assumed to match the order its objects were sent in, so objects are matched back to their backend result by identity (key + version) rather than by position, with a FIFO queue per identity to keep duplicate keys in the same request each paired with their own result. versionID is "" for a keyed (unversioned) delete, matching how both the request and every backend's response represent "no version specified" — as a nil pointer.
func NewChunkReader ¶
func NewHash ¶ added in v1.9.0
NewHash returns the hash.Hash implementing the given checksum algorithm.
func NewS3HostID ¶ added in v1.5.0
func NewS3HostID() string
NewS3HostID generates a new s3-style host ID
func NewS3RequestID ¶ added in v1.5.0
func NewS3RequestID() string
NewS3RequestID returns a request ID, for example "5MRQJ97RHWJ4FMX9".
func NewSignedChunkReader ¶ added in v1.0.10
func NewSignedChunkReader(r io.Reader, authdata AuthData, canonicalString string, derivedKey []byte, date time.Time, chType checksumType, requireTrailer bool, cLength int64) (io.Reader, error)
NewChunkReader reads from request body io.Reader and parses out the chunk metadata in stream. The headers are validated for proper signatures. Reading from the chunk reader will read only the object data stream without the chunk headers/trailers. derivedKey is the same SigV4 kSigning value the seed request's Authorization header was already checked against, reused here rather than re-derived or re-fetched.
func NewTLSListener ¶ added in v1.2.0
func NewTLSListener(network string, address string, getCertificateFunc func(*tls.ClientHelloInfo) (*tls.Certificate, error)) (net.Listener, error)
func ParsObjectLockHdrs ¶
ParsObjectLockHdrs parses and validates the Object Lock headers of an object write. A header sent with an empty value is validated, not ignored. Whether a header is sent is told by its name: fasthttp may hold an empty value as a nil slice, so Peek returning nil doesn't mean it is absent.
func ParseContentEncoding ¶ added in v1.9.0
ParseContentEncoding returns the Content-Encoding to store for a request, dropping the aws-chunked token unless the request declares a non streaming payload type in x-amz-content-sha256.
S3 keys this on the declaration alone. A streaming payload type frames the body in aws-chunked, and a request that declares no payload type - a presigned URL, signed as UNSIGNED-PAYLOAD and carrying no header - may frame it too, so both drop the token. A declared hex digest or UNSIGNED-PAYLOAD says the body is sent as-is, so there the token is a coding the client chose and is stored as sent.
S3 applies this to the Content-Encoding header itself, before any API sees it, so every controller that reads the header inherits it - including CopyObject and CreateMultipartUpload, which carry no body to frame. POSTObject takes its value from a form field and ignores the header, so it stores the token as sent and must not call this.
func ParseCreateMpChecksumHeaders ¶ added in v1.0.11
func ParseCreateMpChecksumHeaders(ctx fiber.Ctx) (types.ChecksumAlgorithm, types.ChecksumType, error)
Parses and validates the x-amz-checksum-algorithm and x-amz-checksum-type headers
func ParseDecodedContentLength ¶ added in v1.0.20
ParseDecodedContentLength extracts and validates the 'x-amz-decoded-content-length' from fiber context
func ParseDeleteObjects ¶
func ParseDeleteObjects(objs []types.ObjectIdentifier) (result []string)
func ParseIfMatchSize ¶ added in v1.0.18
ParseIfMatchSize parses the 'x-amz-if-match-size' to *int64 if parsing fails, returns nil
func ParseMaxLimiter ¶ added in v1.2.0
func ParseMaxLimiter(limiter string, lt LimiterType) (int32, error)
ParseMaxLimiter parses and validates the pagination limiter
- Empty value → return default depending on limiter type.
- Non-numeric or out-of-range → return the corresponding InvalidArgument error.
- Negative values → return specific negative-value errors per limiter type.
- Values above defaultMaxLimiter are clamped.
- The versions_max_keys limiter is normalized to max-keys for validation.
func ParseObjectAttributes ¶
func ParseObjectAttributes(ctx fiber.Ctx) (map[s3response.ObjectAttributes]struct{}, error)
func ParseObjectLockFields ¶ added in v1.9.0
ParseObjectLockFields parses and validates the Object Lock fields of a browser-based POST upload form, whose field names are lowercase. A field sent with an empty value is validated, not ignored.
func ParsePreconditionDateHeader ¶ added in v1.0.18
ParsePreconditionDateHeader tries to parse the given date string as - RFC1123 - RFC3339 both are valid
func ParsePreconditionDateHeaders ¶ added in v1.0.18
ParsePreconditionDateHeaders parses the "If-Modified-Since" and "If-Unmodified-Since" headers from fiber context to *time.Time
func ParsePreconditionMatchHeaders ¶ added in v1.0.18
ParsePreconditionMatchHeaders extracts "If-Match" and "If-None-Match" headers from fiber Ctx
func ParseTagging ¶ added in v1.0.13
Parses and validates tagging
func SetBucketNameValidationStrict ¶ added in v1.0.19
func SetBucketNameValidationStrict(strict bool)
func SetRegionMismatchHeader ¶ added in v1.9.0
SetRegionMismatchHeader reports the region the request should have been signed for in the x-amz-bucket-region response header, when err is a signing region mismatch. HEAD requests carry no response body, so the header is the only channel through which a client can discover the gateway region and retry against it, which is how the aws sdks recover from the mismatch.
func SetResponseHeaders ¶
func SetResponseHeaders(ctx fiber.Ctx, headers []CustomHeader)
func SignPostPolicy ¶ added in v1.4.0
SignPostPolicy signs a POST-policy document with derivedKey
func StreamResponseBody ¶ added in v1.0.10
func StreamResponseBody(ctx fiber.Ctx, rdr io.ReadCloser, bodysize int)
Streams the response body by chunks
func TrimQuotes ¶ added in v1.3.0
func ValidateBucketRegion ¶ added in v1.9.0
ValidateBucketRegion checks a ListBuckets bucket-region value. Every bucket lives in the gateway region, so like an S3 regional endpoint the gateway rejects any other region, matching it case-insensitively.
func ValidateCopySource ¶ added in v1.0.17
ValidateCopySource parses and validates the copy-source
func ValidateDate ¶
func ValidateLocationConstraint ¶ added in v1.9.0
ValidateLocationConstraint checks a CreateBucket location constraint. The global endpoint serves us-east-1 and takes no constraint; any other region is a region specific endpoint and requires the constraint to name it.
func ValidateSSEHeaders ¶ added in v1.9.0
func ValidateSSEHeaders(ssec SSECHeaders, serverSideEncryption string) error
ValidateSSEHeaders rejects SSE-C combined with another encryption method and encryption methods that this gateway cannot honor.
func ValidateVersionId ¶ added in v1.0.19
ValidateVersionId ensures the versionId query parameter, if specified, isn't empty. S3 rejects both "?versionId=" and the valueless "?versionId" form, and rejects the request if any of the repeated values is empty.
func ValidateWebsiteRedirectLocation ¶ added in v1.6.0
func WithCopySource ¶ added in v1.0.18
func WithCopySource() preconditionOpt
Types ¶
type AuthData ¶
AuthData is the parsed authorization data from the header.
func ParseAuthorization ¶
ParseAuthorization returns the parsed fields for the aws v4 auth header example authorization string from aws docs: Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request, SignedHeaders=host;range;x-amz-date, Signature=fe5f80f77d5fa3beca038a248ff027d0445342fe2855ddc963176630326f1024
func ParsePresignedURIParts ¶
https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
ParsePresignedURIParts parses and validates request URL query parameters ¶
?X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=access-key-id/20130721/us-east-1/s3/aws4_request &X-Amz-Date=20130721T201207Z &X-Amz-Expires=86400 &X-Amz-SignedHeaders=host &X-Amz-Signature=1e68ad45c1db540284a4a1eca3884c293ba1a0ff63ab9db9a15b5b29dfa02cd8
type ChecksumValues ¶ added in v1.0.13
type ChecksumValues map[types.ChecksumAlgorithm]string
func ParseCalculatedChecksumFields ¶ added in v1.4.0
func ParseCalculatedChecksumFields(fields map[string]string) (ChecksumValues, error)
ParseCalculatedChecksumFields parses and validates object POST checksum fields
func ParseCalculatedChecksumHeaders ¶ added in v1.0.17
func ParseCalculatedChecksumHeaders(ctx fiber.Ctx) (ChecksumValues, error)
ParseCalculatedChecksumHeaders parses and validates x-amz-checksum-x header keys e.g x-amz-checksum-crc32, x-amz-checksum-sha256 ...
func ParseChecksumHeadersAndSdkAlgo ¶ added in v1.0.17
func ParseChecksumHeadersAndSdkAlgo(ctx fiber.Ctx) (types.ChecksumAlgorithm, ChecksumValues, error)
ParseChecksumHeadersAndSdkAlgo parses/validates 'x-amz-sdk-checksum-algorithm' and 'x-amz-checksum-x' precalculated request headers
func ParseCompleteMpChecksumHeaders ¶ added in v1.0.19
func ParseCompleteMpChecksumHeaders(ctx fiber.Ctx) (ChecksumValues, error)
ParseCompleteMpChecksumHeaders parses and validates the 'CompleteMultipartUpload' x-amz-checksum-x headers by supporting both 'checksum' and 'checksum-<part_length>' formats
func (ChecksumValues) Headers ¶ added in v1.0.13
func (cv ChecksumValues) Headers() string
Headers concatinates checksum algorithm by prefixing each with 'x-amz-checksum-' e.g. "x-amz-checksum-crc64nvme, x-amz-checksum-sha1"
type ChunkReader ¶
type ChunkReader struct {
// contains filtered or unexported fields
}
ChunkReader reads from chunked upload request body, and returns object data stream
func (*ChunkReader) Algorithm ¶ added in v1.1.0
func (cr *ChunkReader) Algorithm() string
Algorithm returns the checksum algorithm
func (*ChunkReader) Checksum ¶ added in v1.1.0
func (cr *ChunkReader) Checksum() string
Checksum returns the parsed trailing checksum
type CompositeChecksumReader ¶ added in v1.0.11
type CompositeChecksumReader struct {
// contains filtered or unexported fields
}
func NewCompositeChecksumReader ¶ added in v1.0.11
func NewCompositeChecksumReader(ht HashType) (*CompositeChecksumReader, error)
NewCompositeChecksumReader initializes a composite checksum processor, which decodes and validates the provided checksums and returns the final checksum based on the previous processings.
The supported checksum types are: - CRC32 - CRC32C - SHA1 - SHA256 - SHA512 - MD5 - XXHASH64 - XXHASH3 - XXHASH128
func (*CompositeChecksumReader) Process ¶ added in v1.0.11
func (ccr *CompositeChecksumReader) Process(checksum string) error
Decodes and writes the checksum in the hasher
func (*CompositeChecksumReader) Sum ¶ added in v1.0.11
func (ccr *CompositeChecksumReader) Sum() string
Returns the base64 encoded composite checksum
type ConditionalHeaders ¶ added in v1.0.18
type ConditionalHeaders struct {
IfMatch *string
IfNoneMatch *string
IfModSince *time.Time
IfUnmodeSince *time.Time
}
ConditionalHeaders holds the conditional header values
func ParsePreconditionHeaders ¶ added in v1.0.18
func ParsePreconditionHeaders(ctx fiber.Ctx, opts ...preconditionOpt) ConditionalHeaders
ParsePreconditionHeaders parses the precondition headers: - If-Match - If-None-Match - If-Modified-Since - If-Unmodified-Since
type ContentLengthReader ¶ added in v1.9.0
type ContentLengthReader struct {
// contains filtered or unexported fields
}
ContentLengthReader turns an EOF that arrives before Content-Length bytes were read into an IncompleteBody error.
fasthttp's request stream reports a client that closed the connection in the middle of a fixed-length body as a plain io.EOF (only the chunked transfer-encoding path is converted to io.ErrUnexpectedEOF), and io.Copy treats io.EOF as a normal end of stream. Without this check an aborted upload is committed as a complete, shorter object. aws-chunked bodies do not need this: their chunk readers already validate the framing.
func NewContentLengthReader ¶ added in v1.9.0
func NewContentLengthReader(r io.Reader, contentLength int64) *ContentLengthReader
type ContextKey ¶ added in v1.0.15
type ContextKey = httpctx.ContextKey
Region, StartTime, IsRoot, Account, AccessKey context locals are set to default values in middlewares.SetDefaultValues to avoid the nil interface conversions
type CredentialsScope ¶ added in v1.4.0
type CredentialsScope = sigv4auth.CredentialsScope
func ParseCredentials ¶ added in v1.4.0
func ParseCredentials(input string, errHandler CredsError) (*CredentialsScope, error)
type CredsError ¶ added in v1.4.0
type CustomHeader ¶
type HashReader ¶
type HashReader struct {
// contains filtered or unexported fields
}
HashReader is an io.Reader that calculates the checksum as the data is read
func NewHashReader ¶
NewHashReader intializes an io.Reader from an underlying io.Reader that calculates the checksum while the reader is being read from. If the sum provided is not "", the reader will return an error when the underlying reader returns io.EOF if the checksum does not match the provided expected checksum. If the provided sum is "", then the Sum() method can still be used to get the current checksum for the data read so far.
func (*HashReader) Read ¶
func (hr *HashReader) Read(p []byte) (int, error)
Read allows *HashReader to be used as an io.Reader
func (*HashReader) SetReader ¶ added in v1.0.11
func (hr *HashReader) SetReader(r io.Reader)
func (*HashReader) Sum ¶
func (hr *HashReader) Sum() string
Sum returns the checksum hash of the data read so far
func (*HashReader) Type ¶ added in v1.0.11
func (hr *HashReader) Type() HashType
type HashType ¶
type HashType string
HashType identifies the checksum algorithm to be used
const ( // HashTypeContentMD5 generates MD5 checksum for the Content-MD5 header. HashTypeContentMD5 HashType = "content-md5" // HashTypeMd5 generates MD5 Base64-Encoded checksum for the data stream HashTypeMd5 HashType = "md5" // HashTypeSha256 generates SHA256 Base64-Encoded checksum for the data stream HashTypeSha256 HashType = "sha256" // HashTypeSha256Hex generates SHA256 hex encoded checksum for the data stream HashTypeSha256Hex HashType = "sha256-hex" // HashTypeSha1 generates SHA1 Base64-Encoded checksum for the data stream HashTypeSha1 HashType = "sha1" // HashTypeSha512 generates SHA512 Base64-Encoded checksum for the data stream HashTypeSha512 HashType = "sha512" // HashTypeCRC32 generates CRC32 Base64-Encoded checksum for the data stream HashTypeCRC32 HashType = "crc32" // HashTypeCRC32C generates CRC32C Base64-Encoded checksum for the data stream HashTypeCRC32C HashType = "crc32c" // HashTypeCRC64NVME generates CRC64NVME Base64-Encoded checksum for the data stream HashTypeCRC64NVME HashType = "crc64nvme" // HashTypeXXHASH64 generates XXHASH64 Base64-Encoded checksum for the data stream HashTypeXXHASH64 HashType = "xxhash64" // HashTypeXXHASH3 generates XXHASH3 Base64-Encoded checksum for the data stream HashTypeXXHASH3 HashType = "xxhash3" // HashTypeXXHASH128 generates XXHASH128 Base64-Encoded checksum for the data stream HashTypeXXHASH128 HashType = "xxhash128" // HashTypeNone is a no-op checksum for the data stream HashTypeNone HashType = "none" )
type LimiterType ¶ added in v1.2.0
type LimiterType string
LimiterType represents the name of a pagination limiter parameter.
type MpFileReader ¶ added in v1.4.0
MpFileReader is the streaming interface for the file part of a multipart POST. It extends io.Reader with a Length method that returns the number of file-content bytes actually delivered to callers (boundary and delimiter bytes are not counted).
type MpParseResult ¶ added in v1.4.0
type MpParseResult struct {
// Fields contains all non-file form fields collected before the file part.
Fields map[string]string
// FileRdr streams the file payload without buffering the entire part in memory.
FileRdr MpFileReader
// ContentLength is the expected byte length of the file payload only.
ContentLength int64
}
type MultipartParser ¶ added in v1.4.0
type MultipartParser struct {
// contains filtered or unexported fields
}
MultipartParser parses S3 browser-based POST multipart/form-data in a streaming way. It buffers regular form fields, but it does not buffer the file part.
func NewMultipartParser ¶ added in v1.4.0
func NewMultipartParser(body io.Reader, boundary string, requestContentLength int64) (*MultipartParser, error)
NewMultipartParser creates a new streaming multipart parser. boundary should be the raw boundary value from Content-Type,
func (*MultipartParser) Parse ¶ added in v1.4.0
func (mp *MultipartParser) Parse() (*MpParseResult, error)
Parse parses all non-file fields and returns:
- form values
- a streaming file reader
- file content length
The returned file reader MUST be read until EOF, otherwise final-boundary validation is not triggered.
type SSECHeaders ¶ added in v1.9.0
SSECHeaders holds the SSE-C (server-side encryption with customer-provided keys) request values. Unset values are nil.
func ExtractSSECHeaders ¶ added in v1.9.0
func ExtractSSECHeaders(ctx fiber.Ctx) SSECHeaders
ExtractSSECHeaders reads SSE-C request headers without validating them.
func ParseCopySourceSSECHeaders ¶ added in v1.9.0
func ParseCopySourceSSECHeaders(ctx fiber.Ctx) (SSECHeaders, error)
ParseCopySourceSSECHeaders extracts and validates the x-amz-copy-source-server-side-encryption-customer-* request headers.
func ParseSSECFields ¶ added in v1.9.0
func ParseSSECFields(fields map[string]string) (SSECHeaders, error)
ParseSSECFields extracts and validates the SSE-C values from POST object form fields, whose names are expected to be lowercased.
func ParseSSECHeaders ¶ added in v1.9.0
func ParseSSECHeaders(ctx fiber.Ctx) (SSECHeaders, error)
ParseSSECHeaders extracts and validates the x-amz-server-side-encryption-customer-* request headers.
type TagLimit ¶ added in v1.0.13
type TagLimit int
TagLimit specifies the allowed tag count in a tag set
type UnsignedChunkReader ¶ added in v1.0.10
type UnsignedChunkReader struct {
// contains filtered or unexported fields
}
UnsignedChunkReader decodes AWS aws-chunked unsigned streaming request bodies. It strips chunk headers/trailers, validates chunk framing and trailing checksums, and exposes only object payload bytes through Read.
The reader is intentionally streaming: chunk payload bytes are read directly into the caller's buffer. It only keeps bounded header/trailer parsing state and a few counters, so a large client-declared chunk does not become a large allocation in the gateway.
func NewUnsignedChunkReader ¶ added in v1.0.10
func NewUnsignedChunkReader(r io.Reader, ct checksumType, decContentLength int64) (*UnsignedChunkReader, error)
func (*UnsignedChunkReader) Algorithm ¶ added in v1.0.20
func (ucr *UnsignedChunkReader) Algorithm() string
Algorithm returns the checksum algorithm
func (*UnsignedChunkReader) Checksum ¶ added in v1.0.20
func (ucr *UnsignedChunkReader) Checksum() string
Checksum returns the parsed trailing checksum