From 7b7a859a03b5da591d839071818027df00a14b5b Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 1 Apr 2020 01:50:37 +0300 Subject: [PATCH] api: use http request Clone (#1458) Signed-off-by: Vasiliy Tolstov --- api/handler/rpc/rpc.go | 4 ++-- api/router/static/static.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/handler/rpc/rpc.go b/api/handler/rpc/rpc.go index 543f5e8c..b3ab0db5 100644 --- a/api/handler/rpc/rpc.go +++ b/api/handler/rpc/rpc.go @@ -128,7 +128,7 @@ func (h *rpcHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { cx = metadata.MergeContext(cx, md, true) // set merged context to request - *r = *r.WithContext(cx) + *r = *r.Clone(cx) // if stream we currently only support json if isStream(r, service) { @@ -324,7 +324,7 @@ func requestPayload(r *http.Request) ([]byte, error) { } // restore context without fields - *r = *r.WithContext(metadata.NewContext(ctx, md)) + *r = *r.Clone(metadata.NewContext(ctx, md)) for k, v := range matches { ps := strings.Split(k, ".") diff --git a/api/router/static/static.go b/api/router/static/static.go index f391cd5a..3cf3bebe 100644 --- a/api/router/static/static.go +++ b/api/router/static/static.go @@ -262,7 +262,7 @@ func (r *staticRouter) endpoint(req *http.Request) (*endpoint, error) { for k, v := range matches { md[fmt.Sprintf("x-api-field-%s", k)] = v } - *req = *req.WithContext(context.WithValue(ctx, metadata.MetadataKey{}, md)) + *req = *req.Clone(context.WithValue(ctx, metadata.MetadataKey{}, md)) break pathLoop } if !pMatch {