perf[http]: http默认状态码改为ok

This commit is contained in:
godotg
2022-09-28 17:14:56 +08:00
parent 9c79ef74db
commit 9e92a7188d
2 changed files with 3 additions and 3 deletions
@@ -40,8 +40,6 @@ public class HttpServerController {
var response = new HttpHelloResponse();
response.setMessage("Hello, this is the http server!");
attachment.setHttpResponseStatus(HttpResponseStatus.OK);
NetContext.getRouter().send(session, response, attachment);
}
@@ -21,6 +21,7 @@ import com.zfoo.protocol.util.StringUtils;
import com.zfoo.util.ThreadUtils;
import com.zfoo.util.net.HostAndPort;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpResponseStatus;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -47,8 +48,9 @@ public class HttpServerTest {
@Override
public DecodedPacketInfo apply(FullHttpRequest fullHttpRequest) {
var uri = StringUtils.trim(fullHttpRequest.uri());
var attachment = HttpAttachment.valueOf(fullHttpRequest, HttpResponseStatus.OK);
if (uri.equals("/hello")) {
return DecodedPacketInfo.valueOf(HttpHelloRequest.valueOf("other param"), HttpAttachment.valueOf(fullHttpRequest, null));
return DecodedPacketInfo.valueOf(HttpHelloRequest.valueOf("other param"), attachment);
} else {
throw new RunException("未知的http路径[{}]", uri);
}