aboutsummaryrefslogtreecommitdiff
path: root/weed/server/volume_server_handlers_read.go
diff options
context:
space:
mode:
authorKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2025-11-14 06:25:47 +0500
committerGitHub <noreply@github.com>2025-11-13 17:25:47 -0800
commit4477edbcc4cd3adb43b3c42f56010388a4373c20 (patch)
tree21c10233553f0887f65af33b8cbc019d237361e0 /weed/server/volume_server_handlers_read.go
parent0e69f7c91606b42fe2e1e55d65d24659e546bf33 (diff)
downloadseaweedfs-4477edbcc4cd3adb43b3c42f56010388a4373c20.tar.xz
seaweedfs-4477edbcc4cd3adb43b3c42f56010388a4373c20.zip
fix: pass proxied query param (#7477)
* fix: pass proxied query param * fix: use math/rand/v2 * Shuffle condition --------- Co-authored-by: chrislu <chris.lu@gmail.com>
Diffstat (limited to 'weed/server/volume_server_handlers_read.go')
-rw-r--r--weed/server/volume_server_handlers_read.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/weed/server/volume_server_handlers_read.go b/weed/server/volume_server_handlers_read.go
index a12b1aeb2..a29ebd183 100644
--- a/weed/server/volume_server_handlers_read.go
+++ b/weed/server/volume_server_handlers_read.go
@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"io"
+ "math/rand/v2"
"mime"
"net/http"
"net/url"
@@ -59,6 +60,11 @@ func (vs *VolumeServer) proxyReqToTargetServer(w http.ResponseWriter, r *http.Re
NotFound(w)
return
}
+ if len(lookupResult.Locations) >= 2 {
+ rand.Shuffle(len(lookupResult.Locations), func(i, j int) {
+ lookupResult.Locations[i], lookupResult.Locations[j] = lookupResult.Locations[j], lookupResult.Locations[i]
+ })
+ }
var tragetUrl *url.URL
location := fmt.Sprintf("%s:%d", vs.store.Ip, vs.store.Port)
for _, loc := range lookupResult.Locations {
@@ -79,7 +85,9 @@ func (vs *VolumeServer) proxyReqToTargetServer(w http.ResponseWriter, r *http.Re
// proxy client request to target server
r.URL.Host = tragetUrl.Host
r.URL.Scheme = tragetUrl.Scheme
- r.URL.Query().Add(reqIsProxied, "true")
+ query := r.URL.Query()
+ query.Set(reqIsProxied, "true")
+ r.URL.RawQuery = query.Encode()
request, err := http.NewRequest(http.MethodGet, r.URL.String(), nil)
if err != nil {
glog.V(0).Infof("failed to instance http request of url %s: %v", r.URL.String(), err)