Repository: quarkusio/quarkus
Issue: Resteasy Reactive: Headers manipulated in ServerRequestFilter are not injected properly into rest method

### Describe the bug

When modifying or create a new header in a @ServerRequestFilter annotated method (with or without preMatching = true) does not have an effect on method paramteres injected with `@RestHeader` or `@HeaderParam`. 

E.g. for a method like

```
@GET
	@Produces(MediaType.TEXT_PLAIN)
	public String hello(
			@RestHeader("new-header") String newHeader,
			@RestHeader(HttpHeaders.USER_AGENT) String userAgent,
			HttpHeaders httpHeaders
	) { ... }
```

you will get the original header for the user agent field, no matter what you set to the headers via `ContainerRequestContext.getHeaders().putSingle()` in the `@ServerRequestFilter` annotated method.

However, the modified headers are available in the `HttpHeaders` object you can inject into the method. 

### Expected behavior

The injected headers should reflect the modified values. 

### Actual behavior

The injected headers contain the original request headers instead of the modified ones, which are only available from the `HttpHeaders` object.

### How to Reproduce?

Reproducer: 
[2021-08-10_resteasy-reactive-modify-headers.zip](https://github.com/quarkusio/quarkus/files/6961865/2021-08-10_resteasy-reactive-modify-headers.zip)

1. Download and unzip
2. Start quarkus with `./gradlew quarkusDev`
3. Go to http://localhost:8080/hello
4. You will get a response listing the injected header value as well as the value available from the `HttpHeaders` object. I'd expect them to be the same. 
5. Classes `NewHeaderCreatingRequestFilter` and `UserAgentRequestFilter` create a new header and modifiy the user agent header respectively.

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

_No response_

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

2.1.1

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

_No response_

### Additional information

_No response_

Changed files:
independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java
extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/simple/SimpleQuarkusRestResource.java

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 c1469854c42..e847095bb96 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 f7cd8e532f0..0b699f4ace7 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<String> list = httpHeaders.getMutableHeaders().get(name);
+            if (list == null) {
+                return Collections.emptyList();
+            } else {
+                return list;
+            }
+        }
     }
 
     @Override