From db91a0386e0abf5cf8348fa8995e6ae42ca72d41 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Wed, 11 Aug 2021 12:40:16 +1000 Subject: [PATCH] Inject modified headers Fixes #19317 --- .../simple/SimpleQuarkusRestResource.java | 5 +++-- .../core/ResteasyReactiveRequestContext.java | 21 +++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/simple/SimpleQuarkusRestResource.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/simple/SimpleQuarkusRestResource.java index c1469854c42a1..e847095bb96f4 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/simple/SimpleQuarkusRestResource.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/simple/SimpleQuarkusRestResource.java @@ -33,6 +33,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.ext.Providers; +import org.jboss.resteasy.reactive.RestHeader; import org.jboss.resteasy.reactive.server.SimpleResourceInfo; import io.quarkus.runtime.BlockingOperationControl; @@ -138,8 +139,8 @@ public Response filters(@Context Providers providers) { @GET @Path("filters") - public Response filters(@Context HttpHeaders headers) { - return Response.ok().header("filter-request", headers.getHeaderString("filter-request")).build(); + public Response filters(@Context HttpHeaders headers, @RestHeader("filter-request") String header) { + return Response.ok().header("filter-request", header).build(); } @GET diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java index f7cd8e532f01e..0b699f4ace735 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java @@ -10,6 +10,7 @@ import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Deque; import java.util.LinkedList; import java.util.List; @@ -781,10 +782,22 @@ public void initPathSegments() { @Override public Object getHeader(String name, boolean single) { - if (single) - return serverRequest().getRequestHeader(name); - // empty collections must not be turned to null - return serverRequest().getAllRequestHeaders(name); + if (httpHeaders == null) { + if (single) + return serverRequest().getRequestHeader(name); + // empty collections must not be turned to null + return serverRequest().getAllRequestHeaders(name); + } else { + if (single) + return httpHeaders.getMutableHeaders().getFirst(name); + // empty collections must not be turned to null + List list = httpHeaders.getMutableHeaders().get(name); + if (list == null) { + return Collections.emptyList(); + } else { + return list; + } + } } @Override