Skip to content

Commit cf53c38

Browse files
authored
Add application name on http1 and http2 (#13906)
1 parent da2dd6d commit cf53c38

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/h12/AbstractServerTransportListener.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public abstract class AbstractServerTransportListener<HEADER extends RequestMeta
6565
private RpcInvocationBuildContext context;
6666
private HttpMessageListener httpMessageListener;
6767

68-
public AbstractServerTransportListener(FrameworkModel frameworkModel, URL url, HttpChannel httpChannel) {
68+
protected AbstractServerTransportListener(FrameworkModel frameworkModel, URL url, HttpChannel httpChannel) {
6969
this.frameworkModel = frameworkModel;
7070
this.url = url;
7171
this.httpChannel = httpChannel;
@@ -211,7 +211,10 @@ protected RpcInvocation buildRpcInvocation(RpcInvocationBuildContext context) {
211211
inv.setObjectAttachments(StreamUtils.toAttachments(httpMetadata.headers()));
212212
inv.put(REMOTE_ADDRESS_KEY, httpChannel.remoteAddress());
213213
inv.getAttributes().putAll(context.getAttributes());
214-
214+
String consumerAppName = httpMetadata.headers().getFirst(TripleHeaderEnum.CONSUMER_APP_NAME_KEY.getHeader());
215+
if (null != consumerAppName) {
216+
inv.put(TripleHeaderEnum.CONSUMER_APP_NAME_KEY, consumerAppName);
217+
}
215218
// customizer RpcInvocation
216219
headerFilters.forEach(f -> f.invoke(invoker, inv));
217220

dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/h12/grpc/GrpcHttp2ServerTransportListener.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.apache.dubbo.rpc.model.FrameworkModel;
3535
import org.apache.dubbo.rpc.protocol.tri.DescriptorUtils;
3636
import org.apache.dubbo.rpc.protocol.tri.RpcInvocationBuildContext;
37-
import org.apache.dubbo.rpc.protocol.tri.TripleHeaderEnum;
3837
import org.apache.dubbo.rpc.protocol.tri.compressor.DeCompressor;
3938
import org.apache.dubbo.rpc.protocol.tri.compressor.Identity;
4039
import org.apache.dubbo.rpc.protocol.tri.h12.HttpMessageListener;
@@ -120,11 +119,6 @@ protected RpcInvocation onBuildRpcInvocationCompletion(RpcInvocation invocation)
120119
getContext().getServiceDescriptor().getInterfaceName(),
121120
getContext().getMethodName()));
122121
}
123-
String consumerAppKey =
124-
getHttpMetadata().headers().getFirst(TripleHeaderEnum.CONSUMER_APP_NAME_KEY.getHeader());
125-
if (null != consumerAppKey) {
126-
invocation.put(TripleHeaderEnum.CONSUMER_APP_NAME_KEY, consumerAppKey);
127-
}
128122
return invocation;
129123
}
130124

0 commit comments

Comments
 (0)