From b0d535d5a771855f64c01fc24f68d8bbc993b5fc Mon Sep 17 00:00:00 2001 From: jojoliang Date: Mon, 11 Nov 2024 16:58:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9url=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E5=B8=A6path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cos.go | 11 ++++++----- cos_test.go | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) 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) }