Copilot commented on code in PR #3428:
URL: https://github.com/apache/dubbo-go/pull/3428#discussion_r3417592010


##########
protocol/triple/triple_protocol/header.go:
##########
@@ -104,7 +103,7 @@ func newIncomingContext(ctx context.Context, data 
http.Header) context.Context {
        }
 
        for key, vals := range data {
-               header[strings.ToLower(key)] = vals
+               header[http.CanonicalHeaderKey(key)] = vals
        }

Review Comment:
   newIncomingContext copies the header map but reuses the underlying value 
slices from the original http.Header and also mutates the existing extraData 
map in-place. Since FromIncomingContext exposes the returned http.Header to 
user code (and http.Header.Values returns the underlying slice), callers can 
inadvertently mutate the original request/response headers (and/or other 
contexts sharing extraData), potentially causing surprising behavior or data 
races. Clone extraData (like NewOutgoingContext does) and deep-copy each 
[]string value slice when building the incoming header map.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to