|
|
@ -17,6 +17,8 @@ |
|
|
|
package cmd |
|
|
|
package cmd |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
|
|
|
|
"context" |
|
|
|
|
|
|
|
"io" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
|
@ -157,6 +159,10 @@ func (api objectAPIHandlers) ListObjectsV2MHandler(w http.ResponseWriter, r *htt |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if proxyListRequest(ctx, w, r, bucket) { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
listObjectsV2 := objectAPI.ListObjectsV2 |
|
|
|
listObjectsV2 := objectAPI.ListObjectsV2 |
|
|
|
|
|
|
|
|
|
|
|
// Inititate a list objects operation based on the input params.
|
|
|
|
// Inititate a list objects operation based on the input params.
|
|
|
@ -231,6 +237,10 @@ func (api objectAPIHandlers) ListObjectsV2Handler(w http.ResponseWriter, r *http |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if proxyListRequest(ctx, w, r, bucket) { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
listObjectsV2 := objectAPI.ListObjectsV2 |
|
|
|
listObjectsV2 := objectAPI.ListObjectsV2 |
|
|
|
|
|
|
|
|
|
|
|
// Inititate a list objects operation based on the input params.
|
|
|
|
// Inititate a list objects operation based on the input params.
|
|
|
@ -262,6 +272,43 @@ func (api objectAPIHandlers) ListObjectsV2Handler(w http.ResponseWriter, r *http |
|
|
|
writeSuccessResponseXML(w, encodeResponse(response)) |
|
|
|
writeSuccessResponseXML(w, encodeResponse(response)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func getListEndpoint(bucket string) ListEndpoint { |
|
|
|
|
|
|
|
return globalListEndpoints[crcHashMod(bucket, len(globalListEndpoints))] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Proxy the list request to the right server.
|
|
|
|
|
|
|
|
func proxyListRequest(ctx context.Context, w http.ResponseWriter, r *http.Request, bucket string) (success bool) { |
|
|
|
|
|
|
|
if len(globalListEndpoints) == 0 { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ep := getListEndpoint(bucket) |
|
|
|
|
|
|
|
if ep.isLocal { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ctx = r.Context() |
|
|
|
|
|
|
|
outreq := r.Clone(ctx) |
|
|
|
|
|
|
|
outreq.URL.Scheme = "http" |
|
|
|
|
|
|
|
outreq.URL.Host = ep.host |
|
|
|
|
|
|
|
outreq.URL.Path = r.URL.Path |
|
|
|
|
|
|
|
outreq.Header.Add("Host", r.Host) |
|
|
|
|
|
|
|
if globalIsSSL { |
|
|
|
|
|
|
|
outreq.URL.Scheme = "https" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
outreq.Host = r.Host |
|
|
|
|
|
|
|
res, err := ep.t.RoundTrip(outreq) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for k, vv := range res.Header { |
|
|
|
|
|
|
|
for _, v := range vv { |
|
|
|
|
|
|
|
w.Header().Set(k, v) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
w.WriteHeader(res.StatusCode) |
|
|
|
|
|
|
|
io.Copy(w, res.Body) |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ListObjectsV1Handler - GET Bucket (List Objects) Version 1.
|
|
|
|
// ListObjectsV1Handler - GET Bucket (List Objects) Version 1.
|
|
|
|
// --------------------------
|
|
|
|
// --------------------------
|
|
|
|
// This implementation of the GET operation returns some or all (up to 10000)
|
|
|
|
// This implementation of the GET operation returns some or all (up to 10000)
|
|
|
@ -300,6 +347,10 @@ func (api objectAPIHandlers) ListObjectsV1Handler(w http.ResponseWriter, r *http |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if proxyListRequest(ctx, w, r, bucket) { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
listObjects := objectAPI.ListObjects |
|
|
|
listObjects := objectAPI.ListObjects |
|
|
|
|
|
|
|
|
|
|
|
// Inititate a list objects operation based on the input params.
|
|
|
|
// Inititate a list objects operation based on the input params.
|
|
|
|