This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.3 by this push:
new 80ffcd7a85 fix(triple): Fix http GET failed cause by http1 upgrade
cause (#14223)
80ffcd7a85 is described below
commit 80ffcd7a85720aae633bc5b3cf16963112a96012
Author: Sean Yang <[email protected]>
AuthorDate: Tue May 21 18:56:20 2024 +0800
fix(triple): Fix http GET failed cause by http1 upgrade cause (#14223)
---
.../rpc/protocol/tri/TripleHttp2Protocol.java | 2 -
.../tri/h12/HttpServerAfterUpgradeHandler.java | 69 ----------------------
2 files changed, 71 deletions(-)
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java
index 4e91dabb35..2a8b539527 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java
@@ -34,7 +34,6 @@ import org.apache.dubbo.remoting.utils.UrlUtils;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.FrameworkModel;
import org.apache.dubbo.rpc.model.ScopeModelAware;
-import org.apache.dubbo.rpc.protocol.tri.h12.HttpServerAfterUpgradeHandler;
import org.apache.dubbo.rpc.protocol.tri.h12.TripleProtocolDetector;
import
org.apache.dubbo.rpc.protocol.tri.h12.http1.DefaultHttp11ServerTransportListenerFactory;
import
org.apache.dubbo.rpc.protocol.tri.h12.http2.GenericHttp2ServerTransportListenerFactory;
@@ -160,7 +159,6 @@ public class TripleHttp2Protocol extends
AbstractWireProtocol implements ScopeMo
ConfigurationUtils.getGlobalConfiguration(url.getOrDefaultApplicationModel());
return new Http2ServerUpgradeCodec(
buildHttp2FrameCodec(config,
url.getOrDefaultApplicationModel()),
- new HttpServerAfterUpgradeHandler(),
new HttpWriteQueueHandler(),
new FlushConsolidationHandler(64, true),
new TripleServerConnectionHandler(),
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/h12/HttpServerAfterUpgradeHandler.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/h12/HttpServerAfterUpgradeHandler.java
deleted file mode 100644
index 30c89087d5..0000000000
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/h12/HttpServerAfterUpgradeHandler.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.rpc.protocol.tri.h12;
-
-import io.netty.channel.ChannelHandler.Sharable;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.handler.codec.http.HttpServerUpgradeHandler;
-import io.netty.handler.codec.http2.DefaultHttp2DataFrame;
-import io.netty.handler.codec.http2.DefaultHttp2Headers;
-import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame;
-import io.netty.handler.codec.http2.Http2CodecUtil;
-import io.netty.handler.codec.http2.Http2FrameCodec;
-import io.netty.handler.codec.http2.Http2FrameStream;
-import io.netty.handler.codec.http2.Http2Headers;
-import io.netty.handler.codec.http2.InboundHttpToHttp2Adapter;
-
-import static io.netty.handler.codec.http.HttpResponseStatus.OK;
-
-/**
- * If an upgrade occurred, the program need send a simple response via HTTP/2
on stream 1 (the stream specifically reserved
- * for cleartext HTTP upgrade). However, {@link Http2FrameCodec} send
'upgradeRequest' to upgraded channel handlers by
- * {@link InboundHttpToHttp2Adapter} (As it noted that this may behave
strangely). So we need to distinguish the 'upgradeRequest'
- * and send the response.<br/>
- *
- * @see HttpServerUpgradeHandler
- * @see Http2FrameCodec
- * @see InboundHttpToHttp2Adapter
- * @since 3.3.0
- */
-@Sharable
-public class HttpServerAfterUpgradeHandler extends
ChannelInboundHandlerAdapter {
-
- @Override
- public void channelRead(ChannelHandlerContext ctx, Object msg) throws
Exception {
- if (msg instanceof DefaultHttp2HeadersFrame) {
- DefaultHttp2HeadersFrame headersFrame = (DefaultHttp2HeadersFrame)
msg;
- if (headersFrame.stream().id() ==
Http2CodecUtil.HTTP_UPGRADE_STREAM_ID && headersFrame.isEndStream()) {
- // upgradeRequest
- sendResponse(ctx, headersFrame.stream());
- return;
- }
- }
- super.channelRead(ctx, msg);
- }
-
- /**
- * Send a frame for the response status
- */
- private static void sendResponse(ChannelHandlerContext ctx,
Http2FrameStream stream) {
- Http2Headers headers = new
DefaultHttp2Headers().status(OK.codeAsText());
- ctx.write(new DefaultHttp2HeadersFrame(headers).stream(stream));
- ctx.write(new DefaultHttp2DataFrame(true).stream(stream));
- }
-}