Revert "HEAD operation changes to fasthttp"

This reverts commit 58f126fd27.
This commit is contained in:
Chris Lu
2020-02-10 13:43:53 -08:00
parent 58f126fd27
commit 33b3bd467c
5 changed files with 15 additions and 59 deletions

View File

@@ -1,17 +1,13 @@
package operation
import (
"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 *Volum
func 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)