[#583] Fix list-buckets vhs routing
All checks were successful
/ DCO (pull_request) Successful in 7m7s
/ Vulncheck (pull_request) Successful in 7m31s
/ Builds (pull_request) Successful in 2m16s
/ Lint (pull_request) Successful in 2m49s
/ Tests (pull_request) Successful in 8m0s

The problem is that with VHS requests,
the list-buckets operation does not work
because the request is filtered on list-objects-v1.

Signed-off-by: Roman Loginov <r.loginov@yadro.com>
This commit is contained in:
Roman Loginov 2024-12-16 10:52:16 +03:00
parent 8867209e8a
commit 84726f7b7f

View file

@ -138,13 +138,17 @@ func (hf *HandlerFilters) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func (hf *HandlerFilters) match(r *http.Request) http.Handler {
queries := r.URL.Query()
LOOP:
for _, filter := range hf.filters {
if filter.noQueries && len(r.URL.Query()) > 0 {
if filter.noQueries && len(queries) > 0 {
continue
}
if len(filter.allowedQueries) > 0 {
queries := r.URL.Query()
if len(queries) == 0 {
continue
}
for key := range queries {
if _, ok := filter.allowedQueries[key]; !ok {
continue LOOP
@ -158,8 +162,8 @@ LOOP:
}
}
for _, query := range filter.queries {
queryVal := r.URL.Query().Get(query.Key)
if !r.URL.Query().Has(query.Key) || query.Value != "" && query.Value != queryVal {
queryVal := queries.Get(query.Key)
if !queries.Has(query.Key) || query.Value != "" && query.Value != queryVal {
continue LOOP
}
}