mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
fix: add missing content-disposition from CORS handler (#10137)
This commit is contained in:
parent
9108abf204
commit
47e304d03c
@ -322,7 +322,7 @@ func corsHandler(handler http.Handler) http.Handler {
|
|||||||
xhttp.ContentEncoding,
|
xhttp.ContentEncoding,
|
||||||
xhttp.ContentLength,
|
xhttp.ContentLength,
|
||||||
xhttp.ContentType,
|
xhttp.ContentType,
|
||||||
xhttp.ContentEncoding,
|
xhttp.ContentDisposition,
|
||||||
xhttp.LastModified,
|
xhttp.LastModified,
|
||||||
xhttp.ContentLanguage,
|
xhttp.ContentLanguage,
|
||||||
xhttp.CacheControl,
|
xhttp.CacheControl,
|
||||||
|
@ -413,6 +413,9 @@ func extractAPIVersion(r *http.Request) string {
|
|||||||
|
|
||||||
// If none of the http routes match respond with appropriate errors
|
// If none of the http routes match respond with appropriate errors
|
||||||
func errorResponseHandler(w http.ResponseWriter, r *http.Request) {
|
func errorResponseHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.Method == http.MethodOptions {
|
||||||
|
return
|
||||||
|
}
|
||||||
version := extractAPIVersion(r)
|
version := extractAPIVersion(r)
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(r.URL.Path, peerRESTPrefix):
|
case strings.HasPrefix(r.URL.Path, peerRESTPrefix):
|
||||||
|
@ -32,6 +32,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
humanize "github.com/dustin/go-humanize"
|
humanize "github.com/dustin/go-humanize"
|
||||||
|
"github.com/minio/minio-go/v7/pkg/set"
|
||||||
xhttp "github.com/minio/minio/cmd/http"
|
xhttp "github.com/minio/minio/cmd/http"
|
||||||
"github.com/minio/minio/pkg/bucket/policy"
|
"github.com/minio/minio/pkg/bucket/policy"
|
||||||
)
|
)
|
||||||
@ -73,6 +74,7 @@ func verifyError(c *check, response *http.Response, code, description string, st
|
|||||||
|
|
||||||
func runAllTests(suite *TestSuiteCommon, c *check) {
|
func runAllTests(suite *TestSuiteCommon, c *check) {
|
||||||
suite.SetUpSuite(c)
|
suite.SetUpSuite(c)
|
||||||
|
suite.TestCors(c)
|
||||||
suite.TestObjectDir(c)
|
suite.TestObjectDir(c)
|
||||||
suite.TestBucketPolicy(c)
|
suite.TestBucketPolicy(c)
|
||||||
suite.TestDeleteBucket(c)
|
suite.TestDeleteBucket(c)
|
||||||
@ -187,6 +189,54 @@ func (s *TestSuiteCommon) TestBucketSQSNotificationWebHook(c *check) {
|
|||||||
verifyError(c, response, "InvalidArgument", "A specified destination ARN does not exist or is not well-formed. Verify the destination ARN.", http.StatusBadRequest)
|
verifyError(c, response, "InvalidArgument", "A specified destination ARN does not exist or is not well-formed. Verify the destination ARN.", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *TestSuiteCommon) TestCors(c *check) {
|
||||||
|
expectedMap := http.Header{}
|
||||||
|
expectedMap.Add("Access-Control-Allow-Credentials", "true")
|
||||||
|
expectedMap.Add("Access-Control-Allow-Origin", "http://foobar.com")
|
||||||
|
expectedMap["Access-Control-Expose-Headers"] = []string{
|
||||||
|
"Date",
|
||||||
|
"Etag",
|
||||||
|
"Server",
|
||||||
|
"Connection",
|
||||||
|
"Accept-Ranges",
|
||||||
|
"Content-Range",
|
||||||
|
"Content-Encoding",
|
||||||
|
"Content-Length",
|
||||||
|
"Content-Type",
|
||||||
|
"Content-Disposition",
|
||||||
|
"Last-Modified",
|
||||||
|
"Content-Language",
|
||||||
|
"Cache-Control",
|
||||||
|
"Retry-After",
|
||||||
|
"X-Amz-Bucket-Region",
|
||||||
|
"Expires",
|
||||||
|
"X-Amz*",
|
||||||
|
"X-Amz*",
|
||||||
|
"*",
|
||||||
|
}
|
||||||
|
expectedMap.Add("Vary", "Origin")
|
||||||
|
|
||||||
|
req, _ := http.NewRequest(http.MethodOptions, s.endPoint, nil)
|
||||||
|
req.Header.Add("Origin", "http://foobar.com")
|
||||||
|
res, err := s.client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
c.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for k := range expectedMap {
|
||||||
|
if v, ok := res.Header[k]; !ok {
|
||||||
|
c.Errorf("Expected key %s missing from %v", k, res.Header)
|
||||||
|
} else {
|
||||||
|
expectedSet := set.CreateStringSet(expectedMap[k]...)
|
||||||
|
gotSet := set.CreateStringSet(strings.Split(v[0], ", ")...)
|
||||||
|
if !expectedSet.Equals(gotSet) {
|
||||||
|
c.Errorf("Expected value %v, got %v", strings.Join(expectedMap[k], ", "), v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (s *TestSuiteCommon) TestObjectDir(c *check) {
|
func (s *TestSuiteCommon) TestObjectDir(c *check) {
|
||||||
bucketName := getRandomBucketName()
|
bucketName := getRandomBucketName()
|
||||||
// HTTP request to create the bucket.
|
// HTTP request to create the bucket.
|
||||||
|
@ -327,7 +327,7 @@ func UnstartedTestServer(t TestErrHandler, instanceType string) TestServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run TestServer.
|
// Run TestServer.
|
||||||
testServer.Server = httptest.NewUnstartedServer(httpHandler)
|
testServer.Server = httptest.NewUnstartedServer(criticalErrorHandler{corsHandler(httpHandler)})
|
||||||
|
|
||||||
globalObjLayerMutex.Lock()
|
globalObjLayerMutex.Lock()
|
||||||
globalObjectAPI = objLayer
|
globalObjectAPI = objLayer
|
||||||
|
Loading…
Reference in New Issue
Block a user