YarBor commented on code in PR #2648:
URL: https://github.com/apache/dubbo-go/pull/2648#discussion_r1564648725


##########
protocol/triple/triple_protocol/header.go:
##########
@@ -88,61 +90,109 @@ func addHeaderCanonical(h http.Header, key, value string) {
        h[key] = append(h[key], value)
 }
 
-type headerIncomingKey struct{}
-type headerOutgoingKey struct{}
+type extraDataKey struct{}
+
+const headerIncomingKey string = "headerIncomingKey"
+const headerOutgoingKey string = "headerOutgoingKey"
+
 type handlerOutgoingKey struct{}
 
 func newIncomingContext(ctx context.Context, header http.Header) 
context.Context {
-       return context.WithValue(ctx, headerIncomingKey{}, header)
+       extraData, ok := ctx.Value(extraDataKey{}).(map[string]http.Header)
+       if !ok {
+               extraData = map[string]http.Header{}
+       }
+       if header == nil {
+               header = make(http.Header)
+       }
+       extraData[headerIncomingKey] = header
+       return context.WithValue(ctx, extraDataKey{}, extraData)
 }
 
 // NewOutgoingContext sets headers entirely. If there are existing headers, 
they would be replaced.
 // It is used for passing headers to server-side.
 // It is like grpc.NewOutgoingContext.
 // Please refer to 
https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md#sending-metadata.
-func NewOutgoingContext(ctx context.Context, header http.Header) 
context.Context {
-       return context.WithValue(ctx, headerOutgoingKey{}, header)
+func NewOutgoingContext(ctx context.Context, data interface{}) 
(context.Context, error) {

Review Comment:
   I will change it back.



-- 
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: notifications-unsubscr...@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to