diff --git a/cos.go b/cos.go index f2ba435..454b218 100644 --- a/cos.go +++ b/cos.go @@ -26,7 +26,7 @@ import ( const ( // Version current go sdk version - Version = "0.7.57" + Version = "0.7.58" UserAgent = "cos-go-sdk-v5/" + Version contentTypeXML = "application/xml" defaultServiceBaseURL = "http://service.cos.myqcloud.com" @@ -86,9 +86,6 @@ func (*BaseURL) innerCheck(u *url.URL, reg *regexp.Regexp) bool { if !strings.HasPrefix(urlStr, "https://") && !strings.HasPrefix(urlStr, "http://") { return false } - if strings.Count(urlStr, "/") > 2 { - return false - } if domainSuffix.MatchString(urlStr) && !reg.MatchString(urlStr) { return false } @@ -232,6 +229,10 @@ func NewClient(uri *BaseURL, httpClient *http.Client) *Client { return c } +func (c *Client) DisableURLCheck() { + c.invalidURL = false +} + type Credential struct { SecretID string SecretKey string @@ -347,7 +348,7 @@ func (c *Client) doAPI(ctx context.Context, req *http.Request, result interface{ ctx, cancel = context.WithCancel(ctx) defer cancel() } - //req = req.WithContext(ctx) + req = req.WithContext(ctx) resp, err := c.client.Do(req) if err != nil { diff --git a/cos_test.go b/cos_test.go index 293be84..a2777a5 100644 --- a/cos_test.go +++ b/cos_test.go @@ -291,7 +291,7 @@ func Test_BaseURL(t *testing.T) { if (&BaseURL{BucketURL: u, ServiceURL: u, BatchURL: u}).Check() { t.Errorf("BaseURL check failed: %v", u) } - u, _ = url.Parse("https://example-125000000.cos.ap-chengdu@123.com/myqcloud.com") + u, _ = url.Parse("https://example-125000000.cos.ap-chengdu@123.com/.myqcloud.com") if (&BaseURL{BucketURL: u, ServiceURL: u, BatchURL: u}).Check() { t.Errorf("BaseURL check failed: %v", u) } @@ -349,7 +349,7 @@ func Test_BaseURL(t *testing.T) { if (&BaseURL{BatchURL: u}).Check() { t.Errorf("BaseURL check failed: %v", u) } - u, _ = url.Parse("http://cos-control.ap-guangzhou.myqcloud.com/www.com") + u, _ = url.Parse("http://cos-control.ap-guangzhou.myqcloud.com") if (&BaseURL{BatchURL: u}).Check() { t.Errorf("BaseURL check failed: %v", u) }