SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
Revert "HEAD operation changes to fasthttp"
Chris Lu33b3bd467cfa
diff --git a/go.mod b/go.modindex 0bf76980e5..48879fd8c4 100644--- a/go.mod+++ b/go.mod@@ -36,6 +36,7 @@ require (github.com/jcmturner/gofork v1.0.0 // indirectgithub.com/karlseguin/ccache v2.0.3+incompatiblegithub.com/karlseguin/expect v1.0.1 // indirect+ github.com/klauspost/cpuid v1.2.1 // indirectgithub.com/klauspost/crc32 v1.2.0github.com/klauspost/reedsolomon v1.9.2github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect@@ -75,7 +76,6 @@ require (github.com/uber-go/atomic v1.4.0 // indirectgithub.com/uber/jaeger-client-go v2.17.0+incompatible // indirectgithub.com/uber/jaeger-lib v2.0.0+incompatible // indirect- github.com/valyala/fasthttp v1.9.0github.com/willf/bitset v1.1.10 // indirectgithub.com/willf/bloom v2.0.3+incompatiblegithub.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0 // indirectdiff --git a/go.sum b/go.sumindex 132119abd2..d162805684 100644--- a/go.sum+++ b/go.sum@@ -282,8 +282,6 @@ github.com/karlseguin/expect v1.0.1/go.mod h1:zNBxMY8P21owkeogJELCLeHIt+voOSduHYgithub.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=-github.com/klauspost/compress v1.8.2 h1:Bx0qjetmNjdFXASH02NSAREKpiaDwkO1DRZ3dV2KCcs=-github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w=github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=@@ -547,11 +545,6 @@ github.com/unrolled/render v0.0.0-20180914162206-b9786414de4d h1:ggUgChAeyge4NZ4github.com/unrolled/render v0.0.0-20180914162206-b9786414de4d/go.mod h1:tu82oB5W2ykJRVioYsB+IQKcft7ryBr7w12qMBUPyXg=github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=github.com/urfave/negroni v0.3.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=-github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=-github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=-github.com/valyala/fasthttp v1.9.0 h1:hNpmUdy/+ZXYpGy0OBfm7K0UQTzb73W0T0U4iJIVrMw=-github.com/valyala/fasthttp v1.9.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=-github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc=github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=github.com/willf/bloom v2.0.3+incompatible h1:QDacWdqcAUI1MPOwIQZRy9kOR7yxfyEmxX8Wdm2/JPA=@@ -633,7 +626,6 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxRgolang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=golang.org/x/net v0.0.0-20190619014844-b5b0513f8c1b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=-golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=golang.org/x/net v0.0.0-20190909003024-a7b16738d86b h1:XfVGCX+0T4WOStkaOsJRllbsiImhB2jgVBGc9L0lPGc=golang.org/x/net v0.0.0-20190909003024-a7b16738d86b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=diff --git a/weed/operation/assign_file_id.go b/weed/operation/assign_file_id.goindex 3f3bb13e0b..b67d8b708d 100644--- a/weed/operation/assign_file_id.go+++ b/weed/operation/assign_file_id.go@@ -1,17 +1,13 @@package operationimport (- "bytes""context""fmt"-- "github.com/valyala/fasthttp"- "google.golang.org/grpc"-- "github.com/chrislusf/seaweedfs/weed/glog""github.com/chrislusf/seaweedfs/weed/pb/master_pb""github.com/chrislusf/seaweedfs/weed/security""github.com/chrislusf/seaweedfs/weed/util"+ "google.golang.org/grpc"+ "strings")type VolumeAssignRequest struct {@@ -93,16 +89,12 @@ func Assign(server string, grpcDialOption grpc.DialOption, primaryRequest *Volumfunc LookupJwt(master string, fileId string) security.EncodedJwt {tokenStr := ""- lookupUrl := fmt.Sprintf("http://%s/dir/lookup?fileId=%s", master, fileId)- err := util.Head(lookupUrl, func(header fasthttp.ResponseHeader) {- bearer := header.Peek("Authorization")- if len(bearer) > 7 && string(bytes.ToUpper(bearer[0:6])) == "BEARER" {- tokenStr = string(bearer[7:])+ if h, e := util.Head(fmt.Sprintf("http://%s/dir/lookup?fileId=%s", master, fileId)); e == nil {+ bearer := h.Get("Authorization")+ if len(bearer) > 7 && strings.ToUpper(bearer[0:6]) == "BEARER" {+ tokenStr = bearer[7:]}- })- if err != nil {- glog.V(0).Infof("failed to lookup jwt %s: %v", lookupUrl, err)}return security.EncodedJwt(tokenStr)diff --git a/weed/util/http_util.go b/weed/util/http_util.goindex b74e30ad7b..08007a0380 100644--- a/weed/util/http_util.go+++ b/weed/util/http_util.go@@ -12,8 +12,6 @@ import ("net/url""strings"- "github.com/valyala/fasthttp"-"github.com/chrislusf/seaweedfs/weed/glog")@@ -85,23 +83,16 @@ func Get(url string) ([]byte, error) {return b, nil}-func Head(url string, fn func(header fasthttp.ResponseHeader)) error {- req := fasthttp.AcquireRequest()- resp := fasthttp.AcquireResponse()- defer fasthttp.ReleaseRequest(req) // <- do not forget to release- defer fasthttp.ReleaseResponse(resp) // <- do not forget to release-- c := fasthttp.Client{}- req.SetRequestURI(url)- req.Header.SetMethod(fasthttp.MethodHead)- if err := c.Do(req, resp); err != nil {- return err+func Head(url string) (http.Header, error) {+ r, err := client.Head(url)+ if err != nil {+ return nil, err}- if resp.StatusCode() >= 400 {- return fmt.Errorf("%s: %d", url, resp.StatusCode())+ defer r.Body.Close()+ if r.StatusCode >= 400 {+ return nil, fmt.Errorf("%s: %s", url, r.Status)}- fn(resp.Header)- return nil+ return r.Header, nil}func Delete(url string, jwt string) error {diff --git a/weed/util/http_util_test.go b/weed/util/http_util_test.godeleted file mode 100644index a8a1172d2b..0000000000--- a/weed/util/http_util_test.go+++ /dev/null@@ -1,19 +0,0 @@-package util--import (- "testing"-- "github.com/valyala/fasthttp"-)--func TestFasthttpClientHead(t *testing.T) {- err := Head("https://www.google.com", func(header fasthttp.ResponseHeader) {- header.VisitAll(func(key, value []byte) {- println(string(key) + ": " + string(value))- })- })- if err != nil {- println(err.Error())- }--}