Skip to content

Commit

Permalink
Inject modified headers
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Aug 11, 2021
1 parent 626b2dc commit db91a03
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit db91a03

Please sign in to comment.