aboutsummaryrefslogtreecommitdiff
path: root/weed/server
diff options
context:
space:
mode:
authorKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2024-07-01 13:00:39 +0500
committerGitHub <noreply@github.com>2024-07-01 01:00:39 -0700
commit5ffacbb6eacaad6ea9558d18f9c62be2a3c4e18f (patch)
treebf5797c6b002d953d03ae68fa37c7c4be7fabc40 /weed/server
parent0fdf7eca48892b5c6d12c1c96563755945331f16 (diff)
downloadseaweedfs-5ffacbb6eacaad6ea9558d18f9c62be2a3c4e18f.tar.xz
seaweedfs-5ffacbb6eacaad6ea9558d18f9c62be2a3c4e18f.zip
refactor all methods strings to const (#5726)
Diffstat (limited to 'weed/server')
-rw-r--r--weed/server/common.go2
-rw-r--r--weed/server/filer_server_handlers_read.go2
-rw-r--r--weed/server/filer_server_handlers_write_autochunk.go2
-rw-r--r--weed/server/volume_server_handlers_read.go8
4 files changed, 7 insertions, 7 deletions
diff --git a/weed/server/common.go b/weed/server/common.go
index 57a073169..7be2f8a76 100644
--- a/weed/server/common.go
+++ b/weed/server/common.go
@@ -127,7 +127,7 @@ func debug(params ...interface{}) {
func submitForClientHandler(w http.ResponseWriter, r *http.Request, masterFn operation.GetMasterFn, grpcDialOption grpc.DialOption) {
m := make(map[string]interface{})
- if r.Method != "POST" {
+ if r.Method != http.MethodPost {
writeJsonError(w, r, http.StatusMethodNotAllowed, errors.New("Only submit via POST!"))
return
}
diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go
index 94e8e4fed..a02e6c2c1 100644
--- a/weed/server/filer_server_handlers_read.go
+++ b/weed/server/filer_server_handlers_read.go
@@ -226,7 +226,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
AdjustPassthroughHeaders(w, r, filename)
totalSize := int64(entry.Size())
- if r.Method == "HEAD" {
+ if r.Method == http.MethodHead {
w.Header().Set("Content-Length", strconv.FormatInt(totalSize, 10))
return
}
diff --git a/weed/server/filer_server_handlers_write_autochunk.go b/weed/server/filer_server_handlers_write_autochunk.go
index 2698e2209..039bad523 100644
--- a/weed/server/filer_server_handlers_write_autochunk.go
+++ b/weed/server/filer_server_handlers_write_autochunk.go
@@ -39,7 +39,7 @@ func (fs *FilerServer) autoChunk(ctx context.Context, w http.ResponseWriter, r *
var reply *FilerPostResult
var err error
var md5bytes []byte
- if r.Method == "POST" {
+ if r.Method == http.MethodPost {
if r.Header.Get("Content-Type") == "" && strings.HasSuffix(r.URL.Path, "/") {
reply, err = fs.mkdir(ctx, w, r, so)
} else {
diff --git a/weed/server/volume_server_handlers_read.go b/weed/server/volume_server_handlers_read.go
index a7f8e9147..ccbd42054 100644
--- a/weed/server/volume_server_handlers_read.go
+++ b/weed/server/volume_server_handlers_read.go
@@ -84,7 +84,7 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
u, _ := url.Parse(util.NormalizeUrl(lookupResult.Locations[0].Url))
r.URL.Host = u.Host
r.URL.Scheme = u.Scheme
- request, err := http.NewRequest("GET", r.URL.String(), nil)
+ 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)
InternalError(w)
@@ -253,7 +253,7 @@ func shouldAttemptStreamWrite(hasLocalVolume bool, ext string, r *http.Request)
if len(ext) > 0 {
ext = strings.ToLower(ext)
}
- if r.Method == "HEAD" {
+ if r.Method == http.MethodHead {
return true, true
}
_, _, _, shouldResize := shouldResizeImages(ext, r)
@@ -379,7 +379,7 @@ func writeResponseContent(filename, mimeType string, rs io.ReadSeeker, w http.Re
AdjustPassthroughHeaders(w, r, filename)
- if r.Method == "HEAD" {
+ if r.Method == http.MethodHead {
w.Header().Set("Content-Length", strconv.FormatInt(totalSize, 10))
return nil
}
@@ -408,7 +408,7 @@ func (vs *VolumeServer) streamWriteResponseContent(filename string, mimeType str
w.Header().Set("Accept-Ranges", "bytes")
AdjustPassthroughHeaders(w, r, filename)
- if r.Method == "HEAD" {
+ if r.Method == http.MethodHead {
w.Header().Set("Content-Length", strconv.FormatInt(totalSize, 10))
return
}