From 76ac58eff791409742ca1dc151939fae33b50b6c Mon Sep 17 00:00:00 2001 From: Li Yazhou Date: Wed, 28 Aug 2024 13:50:02 +0800 Subject: [PATCH 1/4] fix pass user-agent --- restful.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/restful.go b/restful.go index b22030d..f7cc989 100644 --- a/restful.go +++ b/restful.go @@ -308,12 +308,10 @@ func (c *APIClient) authMethod() AuthMethod { func (c *APIClient) makeHeaders(ctx context.Context) (http.Header, error) { headers := http.Header{} headers.Set(WarehouseRoute, "warehouse") + headers.Set(UserAgent, fmt.Sprintf("databend-go/%s", version)) if userAgent, ok := ctx.Value(ContextUserAgentID).(string); ok { headers.Set(UserAgent, fmt.Sprintf("%s/databend-go/%s", version, userAgent)) - } else { - headers.Set(UserAgent, fmt.Sprintf("databend-go/%s", version)) } - headers.Set(UserAgent, fmt.Sprintf("databend-go/%s", version)) if c.tenant != "" { headers.Set(DatabendTenantHeader, c.tenant) } From a6b2bd0e068b5ad3353e10c8dea296bf8469405d Mon Sep 17 00:00:00 2001 From: Li Yazhou Date: Wed, 28 Aug 2024 13:58:26 +0800 Subject: [PATCH 2/4] Revert "fix pass user-agent" This reverts commit 76ac58eff791409742ca1dc151939fae33b50b6c. --- client.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index b3f9d83..54bf561 100644 --- a/client.go +++ b/client.go @@ -309,10 +309,12 @@ func (c *APIClient) authMethod() AuthMethod { func (c *APIClient) makeHeaders(ctx context.Context) (http.Header, error) { headers := http.Header{} headers.Set(WarehouseRoute, "warehouse") - headers.Set(UserAgent, fmt.Sprintf("databend-go/%s", version)) if userAgent, ok := ctx.Value(ContextUserAgentID).(string); ok { headers.Set(UserAgent, fmt.Sprintf("%s/databend-go/%s", version, userAgent)) + } else { + headers.Set(UserAgent, fmt.Sprintf("databend-go/%s", version)) } + headers.Set(UserAgent, fmt.Sprintf("databend-go/%s", version)) if c.tenant != "" { headers.Set(DatabendTenantHeader, c.tenant) } From 726b04e5d5be180320fb3f3c9c1a39e7721441ab Mon Sep 17 00:00:00 2001 From: Li Yazhou Date: Wed, 28 Aug 2024 14:01:36 +0800 Subject: [PATCH 3/4] Revert "Revert "fix pass user-agent"" This reverts commit a6b2bd0e068b5ad3353e10c8dea296bf8469405d. --- client.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client.go b/client.go index 54bf561..b3f9d83 100644 --- a/client.go +++ b/client.go @@ -309,12 +309,10 @@ func (c *APIClient) authMethod() AuthMethod { func (c *APIClient) makeHeaders(ctx context.Context) (http.Header, error) { headers := http.Header{} headers.Set(WarehouseRoute, "warehouse") + headers.Set(UserAgent, fmt.Sprintf("databend-go/%s", version)) if userAgent, ok := ctx.Value(ContextUserAgentID).(string); ok { headers.Set(UserAgent, fmt.Sprintf("%s/databend-go/%s", version, userAgent)) - } else { - headers.Set(UserAgent, fmt.Sprintf("databend-go/%s", version)) } - headers.Set(UserAgent, fmt.Sprintf("databend-go/%s", version)) if c.tenant != "" { headers.Set(DatabendTenantHeader, c.tenant) } From d79c57ee295ec5ba5dac3e73edb2fa257e5b7092 Mon Sep 17 00:00:00 2001 From: Li Yazhou Date: Wed, 28 Aug 2024 14:03:34 +0800 Subject: [PATCH 4/4] tune agent --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index b3f9d83..05af68f 100644 --- a/client.go +++ b/client.go @@ -311,7 +311,7 @@ func (c *APIClient) makeHeaders(ctx context.Context) (http.Header, error) { headers.Set(WarehouseRoute, "warehouse") headers.Set(UserAgent, fmt.Sprintf("databend-go/%s", version)) if userAgent, ok := ctx.Value(ContextUserAgentID).(string); ok { - headers.Set(UserAgent, fmt.Sprintf("%s/databend-go/%s", version, userAgent)) + headers.Set(UserAgent, fmt.Sprintf("databend-go/%s/%s", version, userAgent)) } if c.tenant != "" { headers.Set(DatabendTenantHeader, c.tenant)