refactor all methods strings to const (#5726)

This commit is contained in:
Konstantin Lebedev
2024-07-01 13:00:39 +05:00
committed by GitHub
parent 0fdf7eca48
commit 5ffacbb6ea
18 changed files with 84 additions and 84 deletions

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -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
}