diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-02-10 13:43:53 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-02-10 13:43:53 -0800 |
| commit | 33b3bd467cfa222a910d0298bf3e2a77428ce843 (patch) | |
| tree | 9a4e1db86dd5f26ea831c4af2be1d9cac7e75990 /weed/util/http_util.go | |
| parent | 58f126fd27bb2f366f76f42223b93ba3b31a0bd8 (diff) | |
| download | seaweedfs-33b3bd467cfa222a910d0298bf3e2a77428ce843.tar.xz seaweedfs-33b3bd467cfa222a910d0298bf3e2a77428ce843.zip | |
Revert "HEAD operation changes to fasthttp"
This reverts commit 58f126fd27bb2f366f76f42223b93ba3b31a0bd8.
Diffstat (limited to 'weed/util/http_util.go')
| -rw-r--r-- | weed/util/http_util.go | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/weed/util/http_util.go b/weed/util/http_util.go index b74e30ad7..08007a038 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 { |
