mirror of
https://github.com/pgsty/minio.git
synced 2026-07-19 20:20:25 +03:00
Add x-amz-expiration header in some S3 responses (#9667)
x-amz-expiration is described in the S3 specification as a header which indicates if the object in question will expire any time in the future.
This commit is contained in:
@@ -18,6 +18,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"time"
|
||||
@@ -252,6 +253,19 @@ func isETagEqual(left, right string) bool {
|
||||
return canonicalizeETag(left) == canonicalizeETag(right)
|
||||
}
|
||||
|
||||
// setAmzExpirationHeader sets x-amz-expiration header with expiry time
|
||||
// after analyzing the current bucket lifecycle rules if any.
|
||||
func setAmzExpirationHeader(w http.ResponseWriter, bucket string, objInfo ObjectInfo) {
|
||||
if lc, err := globalLifecycleSys.Get(bucket); err == nil {
|
||||
ruleID, expiryTime := lc.PredictExpiryTime(objInfo.Name, objInfo.UserTags)
|
||||
if !expiryTime.IsZero() {
|
||||
w.Header()[xhttp.AmzExpiration] = []string{
|
||||
fmt.Sprintf(`expiry-date="%s", rule-id="%s"`, expiryTime.Format(http.TimeFormat), ruleID),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// deleteObject is a convenient wrapper to delete an object, this
|
||||
// is a common function to be called from object handlers and
|
||||
// web handlers.
|
||||
|
||||
Reference in New Issue
Block a user