tc native update to 2.0.31, more flexible acceptRequest
This commit is contained in:
parent
2c25413323
commit
ad3fd4fcac
6 changed files with 17 additions and 11 deletions
|
@ -1,11 +1,11 @@
|
|||
group = org.xbib
|
||||
name = netty-http
|
||||
version = 4.1.50.2
|
||||
version = 4.1.50.3
|
||||
|
||||
gradle.wrapper.version = 6.4.1
|
||||
netty.version = 4.1.50.Final
|
||||
tcnative.version = 2.0.29.Final
|
||||
tcnative-legacy-macosx.version = 2.0.26.Final
|
||||
tcnative.version = 2.0.31.Final
|
||||
tcnative-legacy-macosx.version = 2.0.31.Final
|
||||
xbib.net.version = 2.1.0
|
||||
bouncycastle.version = 1.64
|
||||
reactivestreams.version = 1.0.2
|
||||
|
|
|
@ -55,7 +55,9 @@ public abstract class ResourceService implements Filter {
|
|||
protected abstract int getMaxAgeSeconds();
|
||||
|
||||
private void handleCachedResource(ServerRequest serverRequest, ServerResponse serverResponse, Resource resource) {
|
||||
logger.log(Level.FINE, "resource = " + resource);
|
||||
if (logger.isLoggable(Level.FINER)) {
|
||||
logger.log(Level.FINER, "resource = " + resource);
|
||||
}
|
||||
if (resource.isDirectory()) {
|
||||
if (!resource.getResourcePath().isEmpty() && !resource.getResourcePath().endsWith("/")) {
|
||||
// external redirect to
|
||||
|
|
|
@ -93,8 +93,8 @@ public class Http1ChannelInitializer extends ChannelInitializer<Channel>
|
|||
pipeline.addLast("http-server-decompressor",
|
||||
new HttpContentDecompressor());
|
||||
}
|
||||
HttpObjectAggregator httpObjectAggregator = new HttpObjectAggregator(serverConfig.getMaxContentLength(),
|
||||
false);
|
||||
HttpObjectAggregator httpObjectAggregator =
|
||||
new HttpObjectAggregator(serverConfig.getMaxContentLength());
|
||||
httpObjectAggregator.setMaxCumulationBufferComponents(serverConfig.getMaxCompositeBufferComponents());
|
||||
pipeline.addLast("http-server-aggregator", httpObjectAggregator);
|
||||
pipeline.addLast("http-server-pipelining", new HttpPipeliningHandler(serverConfig.getPipeliningCapacity()));
|
||||
|
@ -142,7 +142,7 @@ public class Http1ChannelInitializer extends ChannelInitializer<Channel>
|
|||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
logger.log(Level.WARNING, cause.getMessage(), cause);
|
||||
logger.log(Level.SEVERE, cause.getMessage(), cause);
|
||||
ctx.writeAndFlush(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,
|
||||
HttpResponseStatus.INTERNAL_SERVER_ERROR,
|
||||
Unpooled.copiedBuffer(cause.getMessage().getBytes(StandardCharsets.UTF_8))));
|
||||
|
|
|
@ -6,6 +6,7 @@ import io.netty.handler.codec.http.HttpHeaders;
|
|||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.handler.codec.http.HttpVersion;
|
||||
import org.xbib.netty.http.server.Server;
|
||||
import org.xbib.netty.http.server.ServerConfig;
|
||||
import org.xbib.netty.http.server.api.ServerRequest;
|
||||
import org.xbib.netty.http.server.api.ServerResponse;
|
||||
import org.xbib.netty.http.server.api.ServerTransport;
|
||||
|
@ -33,12 +34,15 @@ abstract class BaseTransport implements ServerTransport {
|
|||
* and required special header handling, possibly returning an
|
||||
* appropriate response.
|
||||
*
|
||||
* @param version the HTTP version of the server
|
||||
* @param serverConfig the server config
|
||||
* @param serverRequest the request
|
||||
* @param serverResponse the response
|
||||
* @return whether further processing should be performed
|
||||
*/
|
||||
static boolean acceptRequest(HttpVersion version, ServerRequest serverRequest, ServerResponse serverResponse) {
|
||||
static boolean acceptRequest(ServerConfig serverConfig,
|
||||
ServerRequest serverRequest,
|
||||
ServerResponse serverResponse) {
|
||||
HttpVersion version = serverConfig.getAddress().getVersion();
|
||||
HttpHeaders reqHeaders = serverRequest.getHeaders();
|
||||
if (version.majorVersion() == 1 || version.majorVersion() == 2) {
|
||||
if (!reqHeaders.contains(HttpHeaderNames.HOST)) {
|
||||
|
|
|
@ -25,7 +25,7 @@ public class Http1Transport extends BaseTransport {
|
|||
serverRequest.setSession(sslHandler.engine().getSession());
|
||||
}
|
||||
HttpServerResponse serverResponse = new HttpServerResponse(server, serverRequest, ctx);
|
||||
if (acceptRequest(server.getServerConfig().getAddress().getVersion(), serverRequest, serverResponse)) {
|
||||
if (acceptRequest(server.getServerConfig(), serverRequest, serverResponse)) {
|
||||
serverRequest.handleParameters();
|
||||
server.handle(serverRequest, serverResponse);
|
||||
} else {
|
||||
|
|
|
@ -27,7 +27,7 @@ public class Http2Transport extends BaseTransport {
|
|||
serverRequest.setRequestId(server.getRequestCounter().incrementAndGet());
|
||||
serverRequest.setStreamId(fullHttpRequest.headers().getInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text()));
|
||||
ServerResponse serverResponse = new Http2ServerResponse(server, serverRequest, ctx);
|
||||
if (acceptRequest(server.getServerConfig().getAddress().getVersion(), serverRequest, serverResponse)) {
|
||||
if (acceptRequest(server.getServerConfig(), serverRequest, serverResponse)) {
|
||||
serverRequest.handleParameters();
|
||||
server.handle(serverRequest, serverResponse);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue