Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ke.like committed Dec 8, 2022
1 parent d6ed04f commit 8a624ff
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ type Client struct {
HTTPClient *http.Client
Region string
AuthVersion AuthVersionType // v1 or v4 signature,default is v1
accessKeyLock sync.RWMutex

accessKeyLock sync.RWMutex
}

func convert(c *Client, projName string) *LogProject {
Expand Down
2 changes: 1 addition & 1 deletion signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (s *SignerV1) Sign(method, uri string, headers map[string]string, body []by
return err
}
digest := base64.StdEncoding.EncodeToString(mac.Sum(nil))
auth := fmt.Sprintf("SLS %v:%v", s.accessKeyID, digest)
auth := fmt.Sprintf("SLS %s:%s", s.accessKeyID, digest)
headers[HTTPHeaderAuthorization] = auth
return nil
}
3 changes: 2 additions & 1 deletion signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ type SignerV1Suite struct {
AccessKeyID string
AccessKeySecret string
Endpoint string
signer Signer

signer Signer
}

func (s *SignerV1Suite) SetupTest() {
Expand Down
7 changes: 0 additions & 7 deletions signature_v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ func (s *SignerV4) Sign(method, uri string, headers map[string]string, body []by
return fmt.Errorf("can't find '%s' header", HTTPHeaderLogDate)
}
date := dateTime[:8]

// If content-type value is empty string, server will ignore it.
// So we add a default value here.
if contentType, ok := headers[HTTPHeaderContentType]; ok && len(contentType) == 0 {
headers[HTTPHeaderContentType] = "application/json"
}

// Host should not contain schema here.
if host, ok := headers[HTTPHeaderHost]; ok {
if strings.HasPrefix(host, "http://") {
Expand Down

0 comments on commit 8a624ff

Please # to comment.