This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch 2.13.x
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 8a1f81d6064b654084eac349286775dbddfdb54e
Author: James Netherton <[email protected]>
AuthorDate: Mon Jan 16 07:47:12 2023 +0000

    Add platform-http test for retrieving an HTTP header with no value
---
 .../platform/http/it/PlatformHttpRouteBuilder.java     | 11 +++++++++++
 .../component/http/server/it/PlatformHttpTest.java     | 18 ++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git 
a/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpRouteBuilder.java
 
b/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpRouteBuilder.java
index 2003c6e599..56290759f5 100644
--- 
a/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpRouteBuilder.java
+++ 
b/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpRouteBuilder.java
@@ -147,6 +147,17 @@ public class PlatformHttpRouteBuilder extends RouteBuilder 
{
                 .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(200))
                 .setBody().constant("");
 
+        from("platform-http:/empty/header")
+                .process(exchange -> {
+                    Message message = exchange.getMessage();
+                    String header = message.getHeader("my-header", 
String.class);
+                    if (header != null) {
+                        message.setBody("Header length was " + 
header.length());
+                    } else {
+                        message.setBody("Header was not present");
+                    }
+                });
+
         // Path parameters
         rest()
                 .get("/platform-http/hello-by-name/{name}")
diff --git 
a/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpTest.java
 
b/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpTest.java
index 84d442b1b6..da6d35b9ec 100644
--- 
a/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpTest.java
+++ 
b/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpTest.java
@@ -361,6 +361,24 @@ class PlatformHttpTest {
                         "component", 
is(PlatformHttpComponent.class.getName()));
     }
 
+    @Test
+    public void emptyHeader() {
+        RestAssured.given()
+                .header("my-header", "")
+                .get("/empty/header")
+                .then()
+                .statusCode(200)
+                .body(equalTo("Header length was 0"));
+
+        // Verify that if the expected header is not found that we get the 
expected response
+        RestAssured.given()
+                .header("my-other-header", "")
+                .get("/empty/header")
+                .then()
+                .statusCode(200)
+                .body(equalTo("Header was not present"));
+    }
+
     private static Method[] httpMethods() {
         return Method.values();
     }

Reply via email to