From 45df60e1973a915dcd9e91ee2d79481a7a0505a1 Mon Sep 17 00:00:00 2001 From: wb-wzc505509 Date: Mon, 7 Sep 2020 14:53:43 +0800 Subject: [PATCH] FixUserAgentError --- tea/tea.go | 4 ++++ tea/tea_test.go | 1 + 2 files changed, 5 insertions(+) diff --git a/tea/tea.go b/tea/tea.go index 562e748..a2f192e 100644 --- a/tea/tea.go +++ b/tea/tea.go @@ -317,6 +317,10 @@ func DoRequest(request *Request, requestRuntime map[string]interface{}) (respons continue } else if key == "host" { httpRequest.Header["Host"] = []string{*value} + delete(httpRequest.Header, "host") + } else if key == "user-agent" { + httpRequest.Header["User-Agent"] = []string{*value} + delete(httpRequest.Header, "user-agent") } else { httpRequest.Header[key] = []string{*value} } diff --git a/tea/tea_test.go b/tea/tea_test.go index ba5b953..8890148 100644 --- a/tea/tea_test.go +++ b/tea/tea_test.go @@ -390,6 +390,7 @@ func Test_DoRequest(t *testing.T) { utils.AssertEqual(t, `Internal error`, err.Error()) request.Headers["host"] = String("tea-cn-hangzhou.aliyuncs.com:80") + request.Headers["user-agent"] = String("test") resp, err = DoRequest(request, runtimeObj) utils.AssertNil(t, resp) utils.AssertEqual(t, `Internal error`, err.Error())