diff --git a/src/main/java/com/corundumstudio/socketio/Configuration.java b/src/main/java/com/corundumstudio/socketio/Configuration.java index 601f2207..02a57d5f 100644 --- a/src/main/java/com/corundumstudio/socketio/Configuration.java +++ b/src/main/java/com/corundumstudio/socketio/Configuration.java @@ -25,6 +25,7 @@ import com.corundumstudio.socketio.protocol.JsonSupport; import com.corundumstudio.socketio.store.MemoryStoreFactory; import com.corundumstudio.socketio.store.StoreFactory; +import io.netty.handler.codec.http.HttpDecoderConfig; import javax.net.ssl.KeyManagerFactory; @@ -92,6 +93,8 @@ public class Configuration { private boolean needClientAuth = false; + private HttpRequestDecoderConfiguration httpRequestDecoderConfiguration = new HttpRequestDecoderConfiguration(); + public Configuration() { } @@ -161,6 +164,7 @@ public Configuration() { setWebsocketCompression(conf.isWebsocketCompression()); setRandomSession(conf.randomSession); setNeedClientAuth(conf.isNeedClientAuth()); + setHttpRequestDecoderConfiguration(conf.getHttpRequestDecoderConfiguration()); } public JsonSupport getJsonSupport() { @@ -618,4 +622,19 @@ public void setNeedClientAuth(boolean needClientAuth) { public boolean isNeedClientAuth() { return needClientAuth; } + + public HttpRequestDecoderConfiguration getHttpRequestDecoderConfiguration() { + return httpRequestDecoderConfiguration; + } + + public void setHttpRequestDecoderConfiguration(HttpRequestDecoderConfiguration httpRequestDecoderConfiguration) { + this.httpRequestDecoderConfiguration = httpRequestDecoderConfiguration; + } + + public HttpDecoderConfig getHttpDecoderConfig() { + return new HttpDecoderConfig() + .setMaxInitialLineLength(httpRequestDecoderConfiguration.getMaxInitialLineLength()) + .setMaxHeaderSize(httpRequestDecoderConfiguration.getMaxHeaderSize()) + .setMaxChunkSize(httpRequestDecoderConfiguration.getMaxChunkSize()); + } } diff --git a/src/main/java/com/corundumstudio/socketio/HttpRequestDecoderConfiguration.java b/src/main/java/com/corundumstudio/socketio/HttpRequestDecoderConfiguration.java new file mode 100644 index 00000000..095c9e93 --- /dev/null +++ b/src/main/java/com/corundumstudio/socketio/HttpRequestDecoderConfiguration.java @@ -0,0 +1,42 @@ +package com.corundumstudio.socketio; + +public class HttpRequestDecoderConfiguration { + + private int maxInitialLineLength; + private int maxHeaderSize; + private int maxChunkSize; + + public HttpRequestDecoderConfiguration(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize) { + this.maxInitialLineLength = maxInitialLineLength; + this.maxHeaderSize = maxHeaderSize; + this.maxChunkSize = maxChunkSize; + } + + public HttpRequestDecoderConfiguration() { + this(4096, 8192, 8192); + } + + public int getMaxInitialLineLength() { + return maxInitialLineLength; + } + + public void setMaxInitialLineLength(int maxInitialLineLength) { + this.maxInitialLineLength = maxInitialLineLength; + } + + public int getMaxHeaderSize() { + return maxHeaderSize; + } + + public void setMaxHeaderSize(int maxHeaderSize) { + this.maxHeaderSize = maxHeaderSize; + } + + public int getMaxChunkSize() { + return maxChunkSize; + } + + public void setMaxChunkSize(int maxChunkSize) { + this.maxChunkSize = maxChunkSize; + } +} diff --git a/src/main/java/com/corundumstudio/socketio/SocketIOChannelInitializer.java b/src/main/java/com/corundumstudio/socketio/SocketIOChannelInitializer.java index aa2b724f..099a6ea0 100644 --- a/src/main/java/com/corundumstudio/socketio/SocketIOChannelInitializer.java +++ b/src/main/java/com/corundumstudio/socketio/SocketIOChannelInitializer.java @@ -167,7 +167,7 @@ protected void addSslHandler(ChannelPipeline pipeline) { * @param pipeline - channel pipeline */ protected void addSocketioHandlers(ChannelPipeline pipeline) { - pipeline.addLast(HTTP_REQUEST_DECODER, new HttpRequestDecoder()); + pipeline.addLast(HTTP_REQUEST_DECODER, new HttpRequestDecoder(configuration.getHttpDecoderConfig())); pipeline.addLast(HTTP_AGGREGATOR, new HttpObjectAggregator(configuration.getMaxHttpContentLength()) { @Override protected Object newContinueResponse(HttpMessage start, int maxContentLength,