You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/08/19 20:44:51 UTC
[GitHub] [camel] chandra-h-bitd opened a new pull request #4105: CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY head…
chandra-h-bitd opened a new pull request #4105:
URL: https://github.com/apache/camel/pull/4105
…er if Exchange.HTTP_PATH header not specified
[ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
[ ] Each commit in the pull request should have a meaningful subject line and body.
[ ] If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
[ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
[ ] Run `mvn clean install -Psourcecheck` in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.
Below are the contribution guidelines:
https://github.com/apache/camel/blob/master/CONTRIBUTING.md
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus commented on pull request #4105: CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY head…
Posted by GitBox <gi...@apache.org>.
davsclaus commented on pull request #4105:
URL: https://github.com/apache/camel/pull/4105#issuecomment-677299058
It would be good if the unit test checks that those 2 headers are as received on the http server. I think (on top of my head) some of those null values can be expected headers. Look at the other tests to see what they do.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] chandra-h-bitd commented on a change in pull request #4105: CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY head…
Posted by GitBox <gi...@apache.org>.
chandra-h-bitd commented on a change in pull request #4105:
URL: https://github.com/apache/camel/pull/4105#discussion_r473331543
##########
File path: components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java
##########
@@ -100,6 +100,10 @@ public Processor createPreProcessor(Exchange exchange, DynamicAwareEntry entry)
query = URISupport.createQueryString(new LinkedHashMap<>(entry.getLenientProperties()));
}
+ if (query == null && exchange.getIn().getHeader(Exchange.HTTP_QUERY) != null) {
Review comment:
Thanks for the suggestion, Used ObjectHelper to check the Header
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus commented on a change in pull request #4105: CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY head…
Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #4105:
URL: https://github.com/apache/camel/pull/4105#discussion_r473904061
##########
File path: components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.apache.http.impl.bootstrap.HttpServer;
+import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.component.http.HttpMethods.GET;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class HttpSendDynamicAwareHeadersTest extends BaseHttpTest {
+
+ private HttpServer localServer;
+
+ @BeforeEach
+ @Override
+ public void setUp() throws Exception {
+ localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
+ .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
+ .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
+ .registerHandler("/dynamicAware", new BasicValidationHandler(GET.name(), null, null, null)).create();
+ localServer.start();
+
+ super.setUp();
+ }
+
+ @AfterEach
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ if (localServer != null) {
+ localServer.stop();
+ }
+ }
+
+ @Override
+ protected RoutesBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:dynamicAwareWithoutPathHeader")
+ .setHeader(Exchange.HTTP_QUERY, constant("par1=val1&par2=val2"))
+ .toD("http://localhost:" + localServer.getLocalPort() + "/dynamicAware");
+ }
+ };
+ }
+
+ @Test
+ public void testDynamicAwareHeadersQuery() throws Exception {
+ Exchange e = fluentTemplate.to("direct:dynamicAwareWithoutPathHeader").send();
+ assertEquals("/dynamicAware", e.getIn().getHeader(Exchange.HTTP_PATH));
+ assertEquals("par1=val1&par2=val2", e.getIn().getHeader(Exchange.HTTP_QUERY));
Review comment:
See something like: https://github.com/apache/camel/blob/master/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersTest.java#L48
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] chandra-h-bitd commented on pull request #4105: CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY head…
Posted by GitBox <gi...@apache.org>.
chandra-h-bitd commented on pull request #4105:
URL: https://github.com/apache/camel/pull/4105#issuecomment-677518260
Thanks @davsclaus, I have changed as suggested.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus commented on a change in pull request #4105: CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY head…
Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #4105:
URL: https://github.com/apache/camel/pull/4105#discussion_r473903642
##########
File path: components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.apache.http.impl.bootstrap.HttpServer;
+import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.component.http.HttpMethods.GET;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class HttpSendDynamicAwareHeadersTest extends BaseHttpTest {
+
+ private HttpServer localServer;
+
+ @BeforeEach
+ @Override
+ public void setUp() throws Exception {
+ localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
+ .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
+ .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
+ .registerHandler("/dynamicAware", new BasicValidationHandler(GET.name(), null, null, null)).create();
+ localServer.start();
+
+ super.setUp();
+ }
+
+ @AfterEach
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ if (localServer != null) {
+ localServer.stop();
+ }
+ }
+
+ @Override
+ protected RoutesBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:dynamicAwareWithoutPathHeader")
+ .setHeader(Exchange.HTTP_QUERY, constant("par1=val1&par2=val2"))
+ .toD("http://localhost:" + localServer.getLocalPort() + "/dynamicAware");
+ }
+ };
+ }
+
+ @Test
+ public void testDynamicAwareHeadersQuery() throws Exception {
+ Exchange e = fluentTemplate.to("direct:dynamicAwareWithoutPathHeader").send();
+ assertEquals("/dynamicAware", e.getIn().getHeader(Exchange.HTTP_PATH));
+ assertEquals("par1=val1&par2=val2", e.getIn().getHeader(Exchange.HTTP_QUERY));
Review comment:
No this just checks that the headers was set via Camel, not really that the HTTP server received those headers. Its something up in your setup you need to add this check
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] chandra-h-bitd commented on pull request #4105: CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY head…
Posted by GitBox <gi...@apache.org>.
chandra-h-bitd commented on pull request #4105:
URL: https://github.com/apache/camel/pull/4105#issuecomment-678395449
@davsclaus , I'm really sorry I couldn't get this. I understood that when the expectedHeaders map is passed in, then those headers will be validated during HTTP stack handle(…) call, what I didn't get is, Will I have to check CamelHttpQuery and CamelHttpPath or I can use TestHeader as in the test you referred?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus merged pull request #4105: CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY head…
Posted by GitBox <gi...@apache.org>.
davsclaus merged pull request #4105:
URL: https://github.com/apache/camel/pull/4105
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus commented on pull request #4105: CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY head…
Posted by GitBox <gi...@apache.org>.
davsclaus commented on pull request #4105:
URL: https://github.com/apache/camel/pull/4105#issuecomment-678787207
I improved the test
https://github.com/apache/camel/commit/cfa02385e771e1f07497b6645929a4fe7d0096d3
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] oscerd commented on a change in pull request #4105: CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY head…
Posted by GitBox <gi...@apache.org>.
oscerd commented on a change in pull request #4105:
URL: https://github.com/apache/camel/pull/4105#discussion_r473314658
##########
File path: components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java
##########
@@ -100,6 +100,10 @@ public Processor createPreProcessor(Exchange exchange, DynamicAwareEntry entry)
query = URISupport.createQueryString(new LinkedHashMap<>(entry.getLenientProperties()));
}
+ if (query == null && exchange.getIn().getHeader(Exchange.HTTP_QUERY) != null) {
Review comment:
Please use ObjectHelper
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org