[ 
https://issues.apache.org/jira/browse/CAMEL-12436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16435627#comment-16435627
 ] 

ASF GitHub Bot commented on CAMEL-12436:
----------------------------------------

davsclaus closed pull request #2289: CAMEL-12436: Fix Undertow to extract body 
message from PATCH request
URL: https://github.com/apache/camel/pull/2289
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
index 91bd8522205..ae1f6fe6e45 100644
--- 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
+++ 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
@@ -124,7 +124,7 @@ public Message toCamelMessage(HttpServerExchange 
httpExchange, Exchange exchange
         } else {
             //extract body by myself if undertow parser didn't handle and the 
method is allowed to have one
             //body is extracted as byte[] then auto TypeConverter kicks in
-            if (Methods.POST.equals(httpExchange.getRequestMethod()) || 
Methods.PUT.equals(httpExchange.getRequestMethod())) {
+            if (Methods.POST.equals(httpExchange.getRequestMethod()) || 
Methods.PUT.equals(httpExchange.getRequestMethod()) || 
Methods.PATCH.equals(httpExchange.getRequestMethod())) {
                 
result.setBody(readFromChannel(httpExchange.getRequestChannel()));
             } else {
                 result.setBody(null);
diff --git 
a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerPatchTest.java
 
b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerPatchTest.java
new file mode 100644
index 00000000000..bfbd59fca2b
--- /dev/null
+++ 
b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerPatchTest.java
@@ -0,0 +1,58 @@
+/**
+ * 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.undertow.rest;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.undertow.BaseUndertowTest;
+import org.junit.Test;
+
+public class RestUndertowProducerPatchTest extends BaseUndertowTest {
+
+    @Test
+    public void testUndertowProducerPatch() throws Exception {
+        String body = "Donald Duck";
+        String id = "123";
+
+        MockEndpoint mock = getMockEndpoint("mock:input");
+        mock.message(0).body().isEqualTo(body);
+        mock.message(0).header("id").isEqualTo(id);
+
+        fluentTemplate.withBody(body).withHeader("id", 
id).to("direct:start").send();
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // configure to use localhost with the given port
+                
restConfiguration().component("undertow").host("localhost").port(getPort());
+
+                from("direct:start")
+                        .to("rest:patch:users/{id}");
+
+                // use the rest DSL to define the rest services
+                rest("/users/")
+                        .patch("{id}")
+                        .to("mock:input");
+            }
+        };
+    }
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> camel-undertow - should extract body message from PATCH request
> ---------------------------------------------------------------
>
>                 Key: CAMEL-12436
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12436
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-undertow
>    Affects Versions: 2.21.0
>            Reporter: Tomas Turek
>            Priority: Major
>
> Undertow component should process body message of HTTP PATCH request.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to