diff --git a/net/src/main/java/com/zfoo/net/core/http/HttpServer.java b/net/src/main/java/com/zfoo/net/core/http/HttpServer.java index c7a5afea..758d9df5 100644 --- a/net/src/main/java/com/zfoo/net/core/http/HttpServer.java +++ b/net/src/main/java/com/zfoo/net/core/http/HttpServer.java @@ -14,7 +14,7 @@ package com.zfoo.net.core.http; import com.zfoo.net.core.AbstractServer; -import com.zfoo.net.handler.HttpDispatcherHandler; +import com.zfoo.net.handler.ServerDispatcherHandler; import com.zfoo.net.handler.codec.http.HttpCodecHandler; import com.zfoo.net.packet.model.DecodedPacketInfo; import com.zfoo.util.net.HostAndPort; @@ -56,7 +56,7 @@ public class HttpServer extends AbstractServer { channel.pipeline().addLast(new ChunkedWriteHandler()); channel.pipeline().addLast(new HttpObjectAggregator(64 * 1024)); channel.pipeline().addLast(new HttpCodecHandler(uriResolver)); - channel.pipeline().addLast(new HttpDispatcherHandler()); + channel.pipeline().addLast(new ServerDispatcherHandler()); } } } diff --git a/net/src/main/java/com/zfoo/net/handler/HttpDispatcherHandler.java b/net/src/main/java/com/zfoo/net/handler/HttpDispatcherHandler.java deleted file mode 100644 index e5cd3c23..00000000 --- a/net/src/main/java/com/zfoo/net/handler/HttpDispatcherHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2020 The zfoo Authors - * - * Licensed 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 com.zfoo.net.handler; - -import com.zfoo.net.NetContext; -import com.zfoo.net.packet.model.DecodedPacketInfo; -import com.zfoo.net.packet.model.HttpPacketAttachment; -import com.zfoo.net.util.SessionUtils; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; - -/** - * @author jaysunxiao - * @version 3.0 - */ -@ChannelHandler.Sharable -public class HttpDispatcherHandler extends ServerDispatcherHandler { - - @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) { - var session = SessionUtils.getSession(ctx); - if (session == null) { - return; - } - DecodedPacketInfo decodedPacketInfo = (DecodedPacketInfo) msg; - - var httpPacketAttachment = (HttpPacketAttachment) decodedPacketInfo.getPacketAttachment(); - if (httpPacketAttachment.getUid() <= 0) { - httpPacketAttachment.useExecutorConsistentHash(session.getSid()); - } - - NetContext.getDispatcher().receive(session, decodedPacketInfo.getPacket(), decodedPacketInfo.getPacketAttachment()); - } -} diff --git a/net/src/main/java/com/zfoo/net/handler/codec/http/HttpCodecHandler.java b/net/src/main/java/com/zfoo/net/handler/codec/http/HttpCodecHandler.java index 56520f02..898c7b55 100644 --- a/net/src/main/java/com/zfoo/net/handler/codec/http/HttpCodecHandler.java +++ b/net/src/main/java/com/zfoo/net/handler/codec/http/HttpCodecHandler.java @@ -21,10 +21,7 @@ import com.zfoo.protocol.util.JsonUtils; import com.zfoo.protocol.util.StringUtils; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageCodec; -import io.netty.handler.codec.http.DefaultFullHttpResponse; -import io.netty.handler.codec.http.FullHttpRequest; -import io.netty.handler.codec.http.HttpHeaderNames; -import io.netty.handler.codec.http.HttpHeaderValues; +import io.netty.handler.codec.http.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,6 +68,10 @@ public class HttpCodecHandler extends MessageToMessageCodec