You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/07/16 16:02:27 UTC
[1/6] camel git commit: CAMEL-8976: Add maxHeadersSize option to
configure the total number of bytes the http headers must be for the server
to accept.
Repository: camel
Updated Branches:
refs/heads/camel-2.15.x adae6f5fa -> 9e2cb5fd6
refs/heads/master 7ef6217df -> 405d55d8c
CAMEL-8976: Add maxHeadersSize option to configure the total number of bytes the http headers must be for the server to accept.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/41b312e2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/41b312e2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/41b312e2
Branch: refs/heads/master
Commit: 41b312e2ca34672672cc9f9540a711e4f594989f
Parents: 7ef6217
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 16 15:49:50 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 16 15:49:50 2015 +0200
----------------------------------------------------------------------
.../http/HttpServerInitializerFactory.java | 4 +-
.../HttpServerSharedInitializerFactory.java | 3 +-
.../netty4/http/NettyHttpConfiguration.java | 16 ++++-
...ySharedHttpServerBootstrapConfiguration.java | 9 +++
.../netty4/http/NettyHttpHeaderMaxSizeTest.java | 62 ++++++++++++++++++++
5 files changed, 89 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/41b312e2/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
index 94fc834..1001560 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
@@ -86,8 +86,8 @@ public class HttpServerInitializerFactory extends ServerInitializerFactory {
LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
pipeline.addLast("ssl", sslHandler);
}
-
- pipeline.addLast("decoder", new HttpRequestDecoder());
+
+ pipeline.addLast("decoder", new HttpRequestDecoder(4096, configuration.getMaxHeaderSize(), 8192));
List<ChannelHandler> decoders = consumer.getConfiguration().getDecoders();
for (int x = 0; x < decoders.size(); x++) {
ChannelHandler decoder = decoders.get(x);
http://git-wip-us.apache.org/repos/asf/camel/blob/41b312e2/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
index 3ed4397..63dc729 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
@@ -82,7 +82,7 @@ public class HttpServerSharedInitializerFactory extends HttpServerInitializerFac
pipeline.addLast("ssl", sslHandler);
}
- pipeline.addLast("decoder", new HttpRequestDecoder());
+ pipeline.addLast("decoder", new HttpRequestDecoder(409, configuration.getMaxHeadersSize(), 8192));
if (configuration.isChunked()) {
pipeline.addLast("aggregator", new HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
}
@@ -92,7 +92,6 @@ public class HttpServerSharedInitializerFactory extends HttpServerInitializerFac
}
pipeline.addLast("handler", channelFactory.getChannelHandler());
-
}
private SSLContext createSSLContext() throws Exception {
http://git-wip-us.apache.org/repos/asf/camel/blob/41b312e2/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
index 468d6f8..bf0eba6 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
@@ -55,6 +55,8 @@ public class NettyHttpConfiguration extends NettyConfiguration {
private boolean send503whenSuspended = true;
@UriParam(defaultValue = "" + 1024 * 1024)
private int chunkedMaxContentLength = 1024 * 1024;
+ @UriParam(defaultValue = "8192")
+ private int maxHeaderSize = 8192;
public NettyHttpConfiguration() {
// we need sync=true as http is request/reply by nature
@@ -220,7 +222,19 @@ public class NettyHttpConfiguration extends NettyConfiguration {
public void setChunkedMaxContentLength(int chunkedMaxContentLength) {
this.chunkedMaxContentLength = chunkedMaxContentLength;
}
-
+
+ public int getMaxHeaderSize() {
+ return maxHeaderSize;
+ }
+
+ /**
+ * The maximum length of all headers.
+ * If the sum of the length of each header exceeds this value, a {@link io.netty.handler.codec.TooLongFrameException} will be raised.
+ */
+ public void setMaxHeaderSize(int maxHeaderSize) {
+ this.maxHeaderSize = maxHeaderSize;
+ }
+
// Don't support allowDefaultCodec
public boolean isAllowDefaultCodec() {
return false;
http://git-wip-us.apache.org/repos/asf/camel/blob/41b312e2/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
index 0dba55d..3161036 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
@@ -23,6 +23,7 @@ public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBoot
private int chunkedMaxContentLength = 1024 * 1024;
private boolean chunked = true;
private boolean compression;
+ private int maxHeadersSize = 8192;
public boolean isChunked() {
return chunked;
@@ -47,4 +48,12 @@ public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBoot
public void setCompression(boolean compression) {
this.compression = compression;
}
+
+ public int getMaxHeadersSize() {
+ return maxHeadersSize;
+ }
+
+ public void setMaxHeadersSize(int maxHeadersSize) {
+ this.maxHeadersSize = maxHeadersSize;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/41b312e2/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeaderMaxSizeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeaderMaxSizeTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeaderMaxSizeTest.java
new file mode 100644
index 0000000..d8d76c8
--- /dev/null
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeaderMaxSizeTest.java
@@ -0,0 +1,62 @@
+/**
+ * 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.camel.component.netty4.http;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.junit.Test;
+
+public class NettyHttpHeaderMaxSizeTest extends BaseNettyTest {
+
+ @Test
+ public void testHttpHeaderMaxSizeOk() throws Exception {
+ HttpClient client = new HttpClient();
+ HttpMethod method = new PostMethod("http://localhost:" + getPort() + "/myapp/mytest");
+
+ method.setRequestHeader("name", "you");
+
+ client.executeMethod(method);
+
+ assertEquals(200, method.getStatusCode());
+ assertEquals("Bye World", method.getResponseBodyAsString());
+ }
+
+ @Test
+ public void testHttpHeaderMaxSizeFail() throws Exception {
+ HttpClient client = new HttpClient();
+ HttpMethod method = new PostMethod("http://localhost:" + getPort() + "/myapp/mytest");
+
+ method.setRequestHeader("name", "12345678901234567890123456789012345678901234567890123456789012345678901234567890");
+
+ client.executeMethod(method);
+
+ assertEquals(400, method.getStatusCode());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from("netty4-http:http://localhost:{{port}}/myapp/mytest?maxHeaderSize=100")
+ .transform().constant("Bye World");
+ }
+ };
+ }
+
+}
[2/6] camel git commit: CAMEL-8976: Add maxHeadersSize option to
configure the total number of bytes the http headers must be for the server
to accept.
Posted by da...@apache.org.
CAMEL-8976: Add maxHeadersSize option to configure the total number of bytes the http headers must be for the server to accept.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0ca892f1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0ca892f1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0ca892f1
Branch: refs/heads/master
Commit: 0ca892f1eea3ca0d5829179363990745db5a9d29
Parents: 41b312e
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 16 15:58:31 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 16 15:58:31 2015 +0200
----------------------------------------------------------------------
.../netty/http/HttpServerPipelineFactory.java | 4 +-
.../http/HttpServerSharedPipelineFactory.java | 2 +-
.../netty/http/NettyHttpConfiguration.java | 17 +++++-
...ySharedHttpServerBootstrapConfiguration.java | 9 +++
.../netty/http/NettyHttpHeaderMaxSizeTest.java | 63 ++++++++++++++++++++
5 files changed, 91 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0ca892f1/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
index 84a4eeb..56095e1 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
@@ -85,8 +85,8 @@ public class HttpServerPipelineFactory extends ServerPipelineFactory {
LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
pipeline.addLast("ssl", sslHandler);
}
-
- pipeline.addLast("decoder", new HttpRequestDecoder());
+
+ pipeline.addLast("decoder", new HttpRequestDecoder(4096, configuration.getMaxHeaderSize(), 8192));
List<ChannelHandler> decoders = consumer.getConfiguration().getDecoders();
for (int x = 0; x < decoders.size(); x++) {
ChannelHandler decoder = decoders.get(x);
http://git-wip-us.apache.org/repos/asf/camel/blob/0ca892f1/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
index f9b4cd0..22eae48 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
@@ -82,7 +82,7 @@ public class HttpServerSharedPipelineFactory extends HttpServerPipelineFactory {
pipeline.addLast("ssl", sslHandler);
}
- pipeline.addLast("decoder", new HttpRequestDecoder());
+ pipeline.addLast("decoder", new HttpRequestDecoder(4096, configuration.getMaxHeaderSize(), 8192));
if (configuration.isChunked()) {
pipeline.addLast("aggregator", new HttpChunkAggregator(configuration.getChunkedMaxContentLength()));
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0ca892f1/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
index 51c907c..7847d96 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
@@ -26,6 +26,7 @@ import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
import org.apache.camel.spi.UriPath;
import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.netty.handler.codec.frame.TooLongFrameException;
/**
* Extended configuration for using HTTP with Netty.
@@ -55,6 +56,8 @@ public class NettyHttpConfiguration extends NettyConfiguration {
private boolean send503whenSuspended = true;
@UriParam(defaultValue = "" + 1024 * 1024)
private int chunkedMaxContentLength = 1024 * 1024;
+ @UriParam(defaultValue = "8192")
+ private int maxHeaderSize = 8192;
public NettyHttpConfiguration() {
// we need sync=true as http is request/reply by nature
@@ -220,7 +223,19 @@ public class NettyHttpConfiguration extends NettyConfiguration {
public void setChunkedMaxContentLength(int chunkedMaxContentLength) {
this.chunkedMaxContentLength = chunkedMaxContentLength;
}
-
+
+ public int getMaxHeaderSize() {
+ return maxHeaderSize;
+ }
+
+ /**
+ * The maximum length of all headers.
+ * If the sum of the length of each header exceeds this value, a {@link TooLongFrameException} will be raised.
+ */
+ public void setMaxHeaderSize(int maxHeaderSize) {
+ this.maxHeaderSize = maxHeaderSize;
+ }
+
// Don't support allowDefaultCodec
public boolean isAllowDefaultCodec() {
return false;
http://git-wip-us.apache.org/repos/asf/camel/blob/0ca892f1/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
index cf785c4..809d82c 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
@@ -23,6 +23,7 @@ public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBoot
private int chunkedMaxContentLength = 1024 * 1024;
private boolean chunked = true;
private boolean compression;
+ private int maxHeaderSize = 8192;
public boolean isChunked() {
return chunked;
@@ -47,4 +48,12 @@ public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBoot
public void setCompression(boolean compression) {
this.compression = compression;
}
+
+ public int getMaxHeaderSize() {
+ return maxHeaderSize;
+ }
+
+ public void setMaxHeaderSize(int maxHeaderSize) {
+ this.maxHeaderSize = maxHeaderSize;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0ca892f1/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpHeaderMaxSizeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpHeaderMaxSizeTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpHeaderMaxSizeTest.java
new file mode 100644
index 0000000..6b897a6
--- /dev/null
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpHeaderMaxSizeTest.java
@@ -0,0 +1,63 @@
+/**
+ * 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.camel.component.netty.http;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.junit.Test;
+
+public class NettyHttpHeaderMaxSizeTest extends BaseNettyTest {
+
+ @Test
+ public void testHttpHeaderMaxSizeOk() throws Exception {
+ HttpClient client = new HttpClient();
+ HttpMethod method = new PostMethod("http://localhost:" + getPort() + "/myapp/mytest");
+
+ method.setRequestHeader("name", "you");
+
+ client.executeMethod(method);
+
+ assertEquals(200, method.getStatusCode());
+ assertEquals("Bye World", method.getResponseBodyAsString());
+ }
+
+ @Test
+ public void testHttpHeaderMaxSizeFail() throws Exception {
+ HttpClient client = new HttpClient();
+ HttpMethod method = new PostMethod("http://localhost:" + getPort() + "/myapp/mytest");
+
+ method.setRequestHeader("name", "12345678901234567890123456789012345678901234567890123456789012345678901234567890");
+
+ client.executeMethod(method);
+
+ assertEquals(404, method.getStatusCode());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from("netty-http:http://localhost:{{port}}/myapp/mytest?maxHeaderSize=100")
+ .transform().constant("Bye World");
+ }
+ };
+ }
+
+
+}
[4/6] camel git commit: CAMEL-8976: Add maxHeadersSize option to
configure the total number of bytes the http headers must be for the server
to accept.
Posted by da...@apache.org.
CAMEL-8976: Add maxHeadersSize option to configure the total number of bytes the http headers must be for the server to accept.
Conflicts:
components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d0f082e3
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d0f082e3
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d0f082e3
Branch: refs/heads/camel-2.15.x
Commit: d0f082e31da7327540d1153e14f52d98555ba6f7
Parents: adae6f5
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 16 15:49:50 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 16 16:04:26 2015 +0200
----------------------------------------------------------------------
.../http/HttpServerInitializerFactory.java | 4 +-
.../HttpServerSharedInitializerFactory.java | 3 +-
.../netty4/http/NettyHttpConfiguration.java | 16 ++++-
...ySharedHttpServerBootstrapConfiguration.java | 9 +++
.../netty4/http/NettyHttpHeaderMaxSizeTest.java | 62 ++++++++++++++++++++
5 files changed, 89 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d0f082e3/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
index 94fc834..1001560 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
@@ -86,8 +86,8 @@ public class HttpServerInitializerFactory extends ServerInitializerFactory {
LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
pipeline.addLast("ssl", sslHandler);
}
-
- pipeline.addLast("decoder", new HttpRequestDecoder());
+
+ pipeline.addLast("decoder", new HttpRequestDecoder(4096, configuration.getMaxHeaderSize(), 8192));
List<ChannelHandler> decoders = consumer.getConfiguration().getDecoders();
for (int x = 0; x < decoders.size(); x++) {
ChannelHandler decoder = decoders.get(x);
http://git-wip-us.apache.org/repos/asf/camel/blob/d0f082e3/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
index 3ed4397..63dc729 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
@@ -82,7 +82,7 @@ public class HttpServerSharedInitializerFactory extends HttpServerInitializerFac
pipeline.addLast("ssl", sslHandler);
}
- pipeline.addLast("decoder", new HttpRequestDecoder());
+ pipeline.addLast("decoder", new HttpRequestDecoder(409, configuration.getMaxHeadersSize(), 8192));
if (configuration.isChunked()) {
pipeline.addLast("aggregator", new HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
}
@@ -92,7 +92,6 @@ public class HttpServerSharedInitializerFactory extends HttpServerInitializerFac
}
pipeline.addLast("handler", channelFactory.getChannelHandler());
-
}
private SSLContext createSSLContext() throws Exception {
http://git-wip-us.apache.org/repos/asf/camel/blob/d0f082e3/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
index 50a4ffb..2e2ce7b 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
@@ -56,6 +56,8 @@ public class NettyHttpConfiguration extends NettyConfiguration {
private int chunkedMaxContentLength = 1024 * 1024;
@UriParam(defaultValue = "true")
private boolean chunked = true;
+ @UriParam(defaultValue = "8192")
+ private int maxHeaderSize = 8192;
public NettyHttpConfiguration() {
// we need sync=true as http is request/reply by nature
@@ -176,7 +178,19 @@ public class NettyHttpConfiguration extends NettyConfiguration {
public void setChunkedMaxContentLength(int chunkedMaxContentLength) {
this.chunkedMaxContentLength = chunkedMaxContentLength;
}
-
+
+ public int getMaxHeaderSize() {
+ return maxHeaderSize;
+ }
+
+ /**
+ * The maximum length of all headers.
+ * If the sum of the length of each header exceeds this value, a {@link io.netty.handler.codec.TooLongFrameException} will be raised.
+ */
+ public void setMaxHeaderSize(int maxHeaderSize) {
+ this.maxHeaderSize = maxHeaderSize;
+ }
+
// Don't support allowDefaultCodec
public boolean isAllowDefaultCodec() {
return false;
http://git-wip-us.apache.org/repos/asf/camel/blob/d0f082e3/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
index 0dba55d..3161036 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
@@ -23,6 +23,7 @@ public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBoot
private int chunkedMaxContentLength = 1024 * 1024;
private boolean chunked = true;
private boolean compression;
+ private int maxHeadersSize = 8192;
public boolean isChunked() {
return chunked;
@@ -47,4 +48,12 @@ public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBoot
public void setCompression(boolean compression) {
this.compression = compression;
}
+
+ public int getMaxHeadersSize() {
+ return maxHeadersSize;
+ }
+
+ public void setMaxHeadersSize(int maxHeadersSize) {
+ this.maxHeadersSize = maxHeadersSize;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/d0f082e3/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeaderMaxSizeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeaderMaxSizeTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeaderMaxSizeTest.java
new file mode 100644
index 0000000..d8d76c8
--- /dev/null
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeaderMaxSizeTest.java
@@ -0,0 +1,62 @@
+/**
+ * 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.camel.component.netty4.http;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.junit.Test;
+
+public class NettyHttpHeaderMaxSizeTest extends BaseNettyTest {
+
+ @Test
+ public void testHttpHeaderMaxSizeOk() throws Exception {
+ HttpClient client = new HttpClient();
+ HttpMethod method = new PostMethod("http://localhost:" + getPort() + "/myapp/mytest");
+
+ method.setRequestHeader("name", "you");
+
+ client.executeMethod(method);
+
+ assertEquals(200, method.getStatusCode());
+ assertEquals("Bye World", method.getResponseBodyAsString());
+ }
+
+ @Test
+ public void testHttpHeaderMaxSizeFail() throws Exception {
+ HttpClient client = new HttpClient();
+ HttpMethod method = new PostMethod("http://localhost:" + getPort() + "/myapp/mytest");
+
+ method.setRequestHeader("name", "12345678901234567890123456789012345678901234567890123456789012345678901234567890");
+
+ client.executeMethod(method);
+
+ assertEquals(400, method.getStatusCode());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from("netty4-http:http://localhost:{{port}}/myapp/mytest?maxHeaderSize=100")
+ .transform().constant("Bye World");
+ }
+ };
+ }
+
+}
[3/6] camel git commit: CAMEL-8976: Add maxHeadersSize option to
configure the total number of bytes the http headers must be for the server
to accept.
Posted by da...@apache.org.
CAMEL-8976: Add maxHeadersSize option to configure the total number of bytes the http headers must be for the server to accept.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/405d55d8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/405d55d8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/405d55d8
Branch: refs/heads/master
Commit: 405d55d8c536d5f6de88c62c57e771f203118f11
Parents: 0ca892f
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 16 16:00:44 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 16 16:00:44 2015 +0200
----------------------------------------------------------------------
.../component/netty/http/NettyHttpConfiguration.java | 2 +-
.../netty4/http/HttpServerSharedInitializerFactory.java | 2 +-
.../component/netty4/http/NettyHttpConfiguration.java | 2 +-
.../http/NettySharedHttpServerBootstrapConfiguration.java | 10 +++++-----
4 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/405d55d8/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
index 7847d96..4e103d7 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
@@ -56,7 +56,7 @@ public class NettyHttpConfiguration extends NettyConfiguration {
private boolean send503whenSuspended = true;
@UriParam(defaultValue = "" + 1024 * 1024)
private int chunkedMaxContentLength = 1024 * 1024;
- @UriParam(defaultValue = "8192")
+ @UriParam(label = "consumer", defaultValue = "8192")
private int maxHeaderSize = 8192;
public NettyHttpConfiguration() {
http://git-wip-us.apache.org/repos/asf/camel/blob/405d55d8/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
index 63dc729..71e9129 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
@@ -82,7 +82,7 @@ public class HttpServerSharedInitializerFactory extends HttpServerInitializerFac
pipeline.addLast("ssl", sslHandler);
}
- pipeline.addLast("decoder", new HttpRequestDecoder(409, configuration.getMaxHeadersSize(), 8192));
+ pipeline.addLast("decoder", new HttpRequestDecoder(409, configuration.getMaxHeaderSize(), 8192));
if (configuration.isChunked()) {
pipeline.addLast("aggregator", new HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
}
http://git-wip-us.apache.org/repos/asf/camel/blob/405d55d8/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
index bf0eba6..ff80318 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
@@ -55,7 +55,7 @@ public class NettyHttpConfiguration extends NettyConfiguration {
private boolean send503whenSuspended = true;
@UriParam(defaultValue = "" + 1024 * 1024)
private int chunkedMaxContentLength = 1024 * 1024;
- @UriParam(defaultValue = "8192")
+ @UriParam(label = "consumer", defaultValue = "8192")
private int maxHeaderSize = 8192;
public NettyHttpConfiguration() {
http://git-wip-us.apache.org/repos/asf/camel/blob/405d55d8/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
index 3161036..f8a70ed 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
@@ -23,7 +23,7 @@ public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBoot
private int chunkedMaxContentLength = 1024 * 1024;
private boolean chunked = true;
private boolean compression;
- private int maxHeadersSize = 8192;
+ private int maxHeaderSize = 8192;
public boolean isChunked() {
return chunked;
@@ -49,11 +49,11 @@ public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBoot
this.compression = compression;
}
- public int getMaxHeadersSize() {
- return maxHeadersSize;
+ public int getMaxHeaderSize() {
+ return maxHeaderSize;
}
- public void setMaxHeadersSize(int maxHeadersSize) {
- this.maxHeadersSize = maxHeadersSize;
+ public void setMaxHeaderSize(int maxHeaderSize) {
+ this.maxHeaderSize = maxHeaderSize;
}
}
[6/6] camel git commit: CAMEL-8976: Add maxHeadersSize option to
configure the total number of bytes the http headers must be for the server
to accept.
Posted by da...@apache.org.
CAMEL-8976: Add maxHeadersSize option to configure the total number of bytes the http headers must be for the server to accept.
Conflicts:
components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9e2cb5fd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9e2cb5fd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9e2cb5fd
Branch: refs/heads/camel-2.15.x
Commit: 9e2cb5fd67c3cb1f17d80dc706d20cfbb1d5126c
Parents: fad6ee5
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 16 16:00:44 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 16 16:06:18 2015 +0200
----------------------------------------------------------------------
.../component/netty/http/NettyHttpConfiguration.java | 2 +-
.../netty4/http/HttpServerSharedInitializerFactory.java | 2 +-
.../component/netty4/http/NettyHttpConfiguration.java | 2 +-
.../http/NettySharedHttpServerBootstrapConfiguration.java | 10 +++++-----
4 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9e2cb5fd/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
index 77b60ea..9fbf2d5 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
@@ -57,7 +57,7 @@ public class NettyHttpConfiguration extends NettyConfiguration {
private int chunkedMaxContentLength = 1024 * 1024;
@UriParam(defaultValue = "true")
private boolean chunked = true;
- @UriParam(defaultValue = "8192")
+ @UriParam(label = "consumer", defaultValue = "8192")
private int maxHeaderSize = 8192;
public NettyHttpConfiguration() {
http://git-wip-us.apache.org/repos/asf/camel/blob/9e2cb5fd/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
index 63dc729..71e9129 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
@@ -82,7 +82,7 @@ public class HttpServerSharedInitializerFactory extends HttpServerInitializerFac
pipeline.addLast("ssl", sslHandler);
}
- pipeline.addLast("decoder", new HttpRequestDecoder(409, configuration.getMaxHeadersSize(), 8192));
+ pipeline.addLast("decoder", new HttpRequestDecoder(409, configuration.getMaxHeaderSize(), 8192));
if (configuration.isChunked()) {
pipeline.addLast("aggregator", new HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
}
http://git-wip-us.apache.org/repos/asf/camel/blob/9e2cb5fd/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
index 2e2ce7b..5618aba 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
@@ -56,7 +56,7 @@ public class NettyHttpConfiguration extends NettyConfiguration {
private int chunkedMaxContentLength = 1024 * 1024;
@UriParam(defaultValue = "true")
private boolean chunked = true;
- @UriParam(defaultValue = "8192")
+ @UriParam(label = "consumer", defaultValue = "8192")
private int maxHeaderSize = 8192;
public NettyHttpConfiguration() {
http://git-wip-us.apache.org/repos/asf/camel/blob/9e2cb5fd/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
index 3161036..f8a70ed 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettySharedHttpServerBootstrapConfiguration.java
@@ -23,7 +23,7 @@ public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBoot
private int chunkedMaxContentLength = 1024 * 1024;
private boolean chunked = true;
private boolean compression;
- private int maxHeadersSize = 8192;
+ private int maxHeaderSize = 8192;
public boolean isChunked() {
return chunked;
@@ -49,11 +49,11 @@ public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBoot
this.compression = compression;
}
- public int getMaxHeadersSize() {
- return maxHeadersSize;
+ public int getMaxHeaderSize() {
+ return maxHeaderSize;
}
- public void setMaxHeadersSize(int maxHeadersSize) {
- this.maxHeadersSize = maxHeadersSize;
+ public void setMaxHeaderSize(int maxHeaderSize) {
+ this.maxHeaderSize = maxHeaderSize;
}
}
[5/6] camel git commit: CAMEL-8976: Add maxHeadersSize option to
configure the total number of bytes the http headers must be for the server
to accept.
Posted by da...@apache.org.
CAMEL-8976: Add maxHeadersSize option to configure the total number of bytes the http headers must be for the server to accept.
Conflicts:
components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fad6ee5a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fad6ee5a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fad6ee5a
Branch: refs/heads/camel-2.15.x
Commit: fad6ee5a3260e089ecfc2a8a5c4864cd692b475f
Parents: d0f082e
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 16 15:58:31 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 16 16:05:17 2015 +0200
----------------------------------------------------------------------
.../netty/http/HttpServerPipelineFactory.java | 4 +-
.../http/HttpServerSharedPipelineFactory.java | 2 +-
.../netty/http/NettyHttpConfiguration.java | 17 +++++-
...ySharedHttpServerBootstrapConfiguration.java | 9 +++
.../netty/http/NettyHttpHeaderMaxSizeTest.java | 63 ++++++++++++++++++++
5 files changed, 91 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/fad6ee5a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
index 84a4eeb..56095e1 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
@@ -85,8 +85,8 @@ public class HttpServerPipelineFactory extends ServerPipelineFactory {
LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
pipeline.addLast("ssl", sslHandler);
}
-
- pipeline.addLast("decoder", new HttpRequestDecoder());
+
+ pipeline.addLast("decoder", new HttpRequestDecoder(4096, configuration.getMaxHeaderSize(), 8192));
List<ChannelHandler> decoders = consumer.getConfiguration().getDecoders();
for (int x = 0; x < decoders.size(); x++) {
ChannelHandler decoder = decoders.get(x);
http://git-wip-us.apache.org/repos/asf/camel/blob/fad6ee5a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
index f9b4cd0..22eae48 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
@@ -82,7 +82,7 @@ public class HttpServerSharedPipelineFactory extends HttpServerPipelineFactory {
pipeline.addLast("ssl", sslHandler);
}
- pipeline.addLast("decoder", new HttpRequestDecoder());
+ pipeline.addLast("decoder", new HttpRequestDecoder(4096, configuration.getMaxHeaderSize(), 8192));
if (configuration.isChunked()) {
pipeline.addLast("aggregator", new HttpChunkAggregator(configuration.getChunkedMaxContentLength()));
}
http://git-wip-us.apache.org/repos/asf/camel/blob/fad6ee5a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
index 28c314d..77b60ea 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
@@ -25,6 +25,7 @@ import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
import org.apache.camel.spi.UriPath;
import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.netty.handler.codec.frame.TooLongFrameException;
/**
* Extended configuration for using HTTP with Netty.
@@ -56,6 +57,8 @@ public class NettyHttpConfiguration extends NettyConfiguration {
private int chunkedMaxContentLength = 1024 * 1024;
@UriParam(defaultValue = "true")
private boolean chunked = true;
+ @UriParam(defaultValue = "8192")
+ private int maxHeaderSize = 8192;
public NettyHttpConfiguration() {
// we need sync=true as http is request/reply by nature
@@ -176,7 +179,19 @@ public class NettyHttpConfiguration extends NettyConfiguration {
public void setChunkedMaxContentLength(int chunkedMaxContentLength) {
this.chunkedMaxContentLength = chunkedMaxContentLength;
}
-
+
+ public int getMaxHeaderSize() {
+ return maxHeaderSize;
+ }
+
+ /**
+ * The maximum length of all headers.
+ * If the sum of the length of each header exceeds this value, a {@link TooLongFrameException} will be raised.
+ */
+ public void setMaxHeaderSize(int maxHeaderSize) {
+ this.maxHeaderSize = maxHeaderSize;
+ }
+
// Don't support allowDefaultCodec
public boolean isAllowDefaultCodec() {
return false;
http://git-wip-us.apache.org/repos/asf/camel/blob/fad6ee5a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
index cf785c4..809d82c 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
@@ -23,6 +23,7 @@ public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBoot
private int chunkedMaxContentLength = 1024 * 1024;
private boolean chunked = true;
private boolean compression;
+ private int maxHeaderSize = 8192;
public boolean isChunked() {
return chunked;
@@ -47,4 +48,12 @@ public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBoot
public void setCompression(boolean compression) {
this.compression = compression;
}
+
+ public int getMaxHeaderSize() {
+ return maxHeaderSize;
+ }
+
+ public void setMaxHeaderSize(int maxHeaderSize) {
+ this.maxHeaderSize = maxHeaderSize;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/fad6ee5a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpHeaderMaxSizeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpHeaderMaxSizeTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpHeaderMaxSizeTest.java
new file mode 100644
index 0000000..6b897a6
--- /dev/null
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpHeaderMaxSizeTest.java
@@ -0,0 +1,63 @@
+/**
+ * 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.camel.component.netty.http;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.junit.Test;
+
+public class NettyHttpHeaderMaxSizeTest extends BaseNettyTest {
+
+ @Test
+ public void testHttpHeaderMaxSizeOk() throws Exception {
+ HttpClient client = new HttpClient();
+ HttpMethod method = new PostMethod("http://localhost:" + getPort() + "/myapp/mytest");
+
+ method.setRequestHeader("name", "you");
+
+ client.executeMethod(method);
+
+ assertEquals(200, method.getStatusCode());
+ assertEquals("Bye World", method.getResponseBodyAsString());
+ }
+
+ @Test
+ public void testHttpHeaderMaxSizeFail() throws Exception {
+ HttpClient client = new HttpClient();
+ HttpMethod method = new PostMethod("http://localhost:" + getPort() + "/myapp/mytest");
+
+ method.setRequestHeader("name", "12345678901234567890123456789012345678901234567890123456789012345678901234567890");
+
+ client.executeMethod(method);
+
+ assertEquals(404, method.getStatusCode());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from("netty-http:http://localhost:{{port}}/myapp/mytest?maxHeaderSize=100")
+ .transform().constant("Bye World");
+ }
+ };
+ }
+
+
+}