S3: Add Vary header for non-wildcard AllowOrigin (#7547)

This commit is contained in:
粒粒橙
2025-11-25 22:19:34 +08:00
committed by GitHub
parent 935c641f25
commit a24c31de06
2 changed files with 6 additions and 0 deletions

View File

@@ -361,6 +361,10 @@ func ApplyHeaders(w http.ResponseWriter, corsResp *CORSResponse) {
if corsResp.AllowOrigin != "" {
w.Header().Set("Access-Control-Allow-Origin", corsResp.AllowOrigin)
if corsResp.AllowOrigin != "*" {
w.Header().Add("Vary", "Origin")
}
}
if corsResp.AllowMethods != "" {

View File

@@ -480,6 +480,7 @@ func TestApplyHeaders(t *testing.T) {
"Access-Control-Allow-Headers": "Content-Type",
"Access-Control-Expose-Headers": "ETag",
"Access-Control-Max-Age": "3600",
"Vary": "Origin",
},
},
{
@@ -493,6 +494,7 @@ func TestApplyHeaders(t *testing.T) {
"Access-Control-Allow-Origin": "http://example.com",
"Access-Control-Allow-Methods": "GET",
"Access-Control-Allow-Credentials": "true",
"Vary": "Origin",
},
},
}