From 31176c491c0acdf517646b474ed0a36c9977026f Mon Sep 17 00:00:00 2001 From: baker-yuan <40530122+baker-yuan@users.noreply.github.com> Date: Sun, 4 Jun 2023 17:21:37 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Ahttp=E8=BD=ACgrpc=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E5=A4=B4=E8=AE=BE=E7=BD=AE=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/plugins/http-to-gRPC/complete.go | 2 +- node/http-context/header.go | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/plugins/http-to-gRPC/complete.go b/drivers/plugins/http-to-gRPC/complete.go index 7f92c381..d832a24d 100644 --- a/drivers/plugins/http-to-gRPC/complete.go +++ b/drivers/plugins/http-to-gRPC/complete.go @@ -183,7 +183,7 @@ type StatusErr struct { func httpHeaderToMD(headers http.Header, additionalHeader map[string]string) []string { headers.Set("content-type", "application/grpc") headers.Del("connection") - md := make([]string, len(headers)+len(additionalHeader)) + md := make([]string, 0, len(headers)+len(additionalHeader)) //md := metadata.New(map[string]string{}) for key, value := range headers { if strings.ToLower(key) == "user-agent" { diff --git a/node/http-context/header.go b/node/http-context/header.go index 41771777..e9b4233d 100644 --- a/node/http-context/header.go +++ b/node/http-context/header.go @@ -159,10 +159,8 @@ func (r *ResponseHeader) Headers() http.Header { func (r *ResponseHeader) SetHeader(key, value string) { r.cache.Set(key, value) - - if r.afterProxy { - r.header.Set(key, value) - } else { + r.header.Set(key, value) + if !r.afterProxy { r.actions = append(r.actions, &headerAction{ Key: key, Value: value,