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/14 10:38:37 UTC
[1/2] camel git commit: CAMEL-8578 - May double encode uri when using
HTTP_URI or HTTP_QUERY headers
Repository: camel
Updated Branches:
refs/heads/master dcdc7760a -> 516834a2a
CAMEL-8578 - May double encode uri when using HTTP_URI or HTTP_QUERY headers
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c9dd906c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c9dd906c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c9dd906c
Branch: refs/heads/master
Commit: c9dd906c783a794293c9e7d4dcda45ea2c069826
Parents: dcdc776
Author: Sami Nurminen <sn...@gmail.com>
Authored: Sun Jul 12 15:24:04 2015 +0300
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 14 10:12:30 2015 +0200
----------------------------------------------------------------------
.../camel/component/http/helper/HttpHelper.java | 2 +-
.../component/http/helper/HttpHelperTest.java | 44 ++++++++++++++++++++
2 files changed, 45 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/c9dd906c/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
index e5bbf45..d4f4620 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
@@ -282,7 +282,7 @@ public final class HttpHelper {
}
// We should user the query string from the HTTP_URI header
if (queryString == null) {
- queryString = uri.getQuery();
+ queryString = uri.getRawQuery();
}
if (queryString != null) {
// need to encode query string
http://git-wip-us.apache.org/repos/asf/camel/blob/c9dd906c/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java
index 6f8f66b..ddbb0b9 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java
@@ -161,6 +161,50 @@ public class HttpHelperTest {
assertEquals(HttpMethods.POST, method);
}
+ @Test
+ public void createURIShouldKeepQueryParametersGivenInUrlParameter() throws URISyntaxException {
+
+ URI uri = HttpHelper.createURI(
+ createExchangeWithOptionalCamelHttpUriHeader(null,
+ null),
+ "http://apache.org/?q=%E2%82%AC"
+ , createHttpEndpoint(false, "http://apache.org"));
+ assertEquals("http://apache.org/?q=%E2%82%AC",uri.toString());
+ }
+
+ @Test
+ public void createURIShouldEncodeExchangeHttpQuery() throws URISyntaxException {
+
+ URI uri = HttpHelper.createURI(
+ createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q= ",
+ null),
+ "http://apache.org/?q=%E2%82%AC"
+ , createHttpEndpoint(false, "http://apache.org"));
+ assertEquals("http://apache.org/?q=%20",uri.toString());
+ }
+
+ @Test
+ public void createURIShouldNotDoubleEncodeExchangeHttpQuery() throws URISyntaxException {
+
+ URI uri = HttpHelper.createURI(
+ createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=%E2%82%AC",
+ null),
+ "http://apache.org/?q=%E2%82%AC"
+ , createHttpEndpoint(false, "http://apache.org"));
+ assertEquals("http://apache.org/?q=%E2%82%AC",uri.toString());
+ }
+
+ @Test
+ public void createURIShouldKeepQueryParametersGivenInEndPointUri() throws URISyntaxException {
+
+ URI uri = HttpHelper.createURI(
+ createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null,
+ null),
+ "http://apache.org/"
+ , createHttpEndpoint(false, "http://apache.org/?q=%E2%82%AC"));
+ assertEquals("http://apache.org/?q=%E2%82%AC",uri.toString());
+ }
+
private Exchange createExchangeWithOptionalHttpQueryAndHttpMethodHeader(String httpQuery, HttpMethods httpMethod) {
CamelContext context = new DefaultCamelContext();
Exchange exchange = new DefaultExchange(context);
[2/2] camel git commit: CAMEL-8578: Fixed CS
Posted by da...@apache.org.
CAMEL-8578: Fixed CS
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/516834a2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/516834a2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/516834a2
Branch: refs/heads/master
Commit: 516834a2a7b9dc84d726a7a76ffdb31b6cc03572
Parents: c9dd906
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 14 10:45:14 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 14 10:45:14 2015 +0200
----------------------------------------------------------------------
.../component/http/helper/HttpHelperTest.java | 61 ++++++--------------
1 file changed, 17 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/516834a2/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java
index ddbb0b9..8cd5d16 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java
@@ -71,7 +71,6 @@ public class HttpHelperTest {
String url = HttpHelper.createURL(
createExchangeWithOptionalCamelHttpUriHeader("http://apache.org", null),
createHttpEndpoint(false, "http://camel.apache.org"));
-
assertEquals("http://apache.org", url);
}
@@ -80,7 +79,6 @@ public class HttpHelperTest {
String url = HttpHelper.createURL(
createExchangeWithOptionalCamelHttpUriHeader("http://apache.org", null),
createHttpEndpoint(true, "http://camel.apache.org"));
-
assertEquals("http://camel.apache.org", url);
}
@@ -89,7 +87,6 @@ public class HttpHelperTest {
String url = HttpHelper.createURL(
createExchangeWithOptionalCamelHttpUriHeader(null, null),
createHttpEndpoint(false, "http://camel.apache.org"));
-
assertEquals("http://camel.apache.org", url);
}
@@ -98,7 +95,6 @@ public class HttpHelperTest {
String url = HttpHelper.createURL(
createExchangeWithOptionalCamelHttpUriHeader(null, "search"),
createHttpEndpoint(true, "http://www.google.com"));
-
assertEquals("http://www.google.com/search", url);
}
@@ -107,7 +103,6 @@ public class HttpHelperTest {
String url = HttpHelper.createURL(
createExchangeWithOptionalCamelHttpUriHeader(null, "/search"),
createHttpEndpoint(true, "http://www.google.com/"));
-
assertEquals("http://www.google.com/search", url);
}
@@ -115,9 +110,7 @@ public class HttpHelperTest {
public void createMethodAlwaysUseUserChoosenMethod() throws URISyntaxException {
HttpMethods method = HttpHelper.createMethod(
createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel", HttpMethods.POST),
- createHttpEndpoint(true, "http://www.google.com/search"),
- false);
-
+ createHttpEndpoint(true, "http://www.google.com/search"), false);
assertEquals(HttpMethods.POST, method);
}
@@ -125,9 +118,7 @@ public class HttpHelperTest {
public void createMethodUseGETIfQueryIsProvidedInHeader() throws URISyntaxException {
HttpMethods method = HttpHelper.createMethod(
createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel", null),
- createHttpEndpoint(true, "http://www.google.com/search"),
- false);
-
+ createHttpEndpoint(true, "http://www.google.com/search"), false);
assertEquals(HttpMethods.GET, method);
}
@@ -135,9 +126,7 @@ public class HttpHelperTest {
public void createMethodUseGETIfQueryIsProvidedInEndpointURI() throws URISyntaxException {
HttpMethods method = HttpHelper.createMethod(
createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
- createHttpEndpoint(true, "http://www.google.com/search?q=test"),
- false);
-
+ createHttpEndpoint(true, "http://www.google.com/search?q=test"), false);
assertEquals(HttpMethods.GET, method);
}
@@ -145,9 +134,7 @@ public class HttpHelperTest {
public void createMethodUseGETIfNoneQueryOrPayloadIsProvided() throws URISyntaxException {
HttpMethods method = HttpHelper.createMethod(
createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
- createHttpEndpoint(true, "http://www.google.com/search"),
- false);
-
+ createHttpEndpoint(true, "http://www.google.com/search"), false);
assertEquals(HttpMethods.GET, method);
}
@@ -155,54 +142,40 @@ public class HttpHelperTest {
public void createMethodUsePOSTIfNoneQueryButPayloadIsProvided() throws URISyntaxException {
HttpMethods method = HttpHelper.createMethod(
createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
- createHttpEndpoint(true, "http://www.google.com/search"),
- true);
-
+ createHttpEndpoint(true, "http://www.google.com/search"), true);
assertEquals(HttpMethods.POST, method);
}
@Test
public void createURIShouldKeepQueryParametersGivenInUrlParameter() throws URISyntaxException {
-
URI uri = HttpHelper.createURI(
- createExchangeWithOptionalCamelHttpUriHeader(null,
- null),
- "http://apache.org/?q=%E2%82%AC"
- , createHttpEndpoint(false, "http://apache.org"));
- assertEquals("http://apache.org/?q=%E2%82%AC",uri.toString());
+ createExchangeWithOptionalCamelHttpUriHeader(null, null),
+ "http://apache.org/?q=%E2%82%AC", createHttpEndpoint(false, "http://apache.org"));
+ assertEquals("http://apache.org/?q=%E2%82%AC", uri.toString());
}
@Test
public void createURIShouldEncodeExchangeHttpQuery() throws URISyntaxException {
-
URI uri = HttpHelper.createURI(
- createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q= ",
- null),
- "http://apache.org/?q=%E2%82%AC"
- , createHttpEndpoint(false, "http://apache.org"));
- assertEquals("http://apache.org/?q=%20",uri.toString());
+ createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q= ", null),
+ "http://apache.org/?q=%E2%82%AC", createHttpEndpoint(false, "http://apache.org"));
+ assertEquals("http://apache.org/?q=%20", uri.toString());
}
@Test
public void createURIShouldNotDoubleEncodeExchangeHttpQuery() throws URISyntaxException {
-
URI uri = HttpHelper.createURI(
- createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=%E2%82%AC",
- null),
- "http://apache.org/?q=%E2%82%AC"
- , createHttpEndpoint(false, "http://apache.org"));
- assertEquals("http://apache.org/?q=%E2%82%AC",uri.toString());
+ createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=%E2%82%AC", null),
+ "http://apache.org/?q=%E2%82%AC", createHttpEndpoint(false, "http://apache.org"));
+ assertEquals("http://apache.org/?q=%E2%82%AC", uri.toString());
}
@Test
public void createURIShouldKeepQueryParametersGivenInEndPointUri() throws URISyntaxException {
-
URI uri = HttpHelper.createURI(
- createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null,
- null),
- "http://apache.org/"
- , createHttpEndpoint(false, "http://apache.org/?q=%E2%82%AC"));
- assertEquals("http://apache.org/?q=%E2%82%AC",uri.toString());
+ createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
+ "http://apache.org/", createHttpEndpoint(false, "http://apache.org/?q=%E2%82%AC"));
+ assertEquals("http://apache.org/?q=%E2%82%AC", uri.toString());
}
private Exchange createExchangeWithOptionalHttpQueryAndHttpMethodHeader(String httpQuery, HttpMethods httpMethod) {