Skip to content

Commit

Permalink
how far without being compliant with the jax-rs spec
Browse files Browse the repository at this point in the history
  • Loading branch information
franz1981 committed Dec 18, 2023
1 parent bedabdd commit 483a24f
Showing 1 changed file with 1 addition and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,7 @@ public void handle(ResteasyReactiveRequestContext requestContext) throws Excepti
}
// according to the spec we need to return HTTP 406 when Accept header doesn't match what is specified in @Produces
if (target.value.getProduces() != null) {
// there could potentially be multiple Accept headers and we need to response with 406
// if none match the method's @Produces
List<String> accepts = (List<String>) requestContext.getHeader(HttpHeaders.ACCEPT, false);
if (!accepts.isEmpty()) {
boolean hasAtLeastOneMatch = false;
for (int i = 0; i < accepts.size(); i++) {
try {
boolean matches = acceptHeaderMatches(target, accepts.get(i));
if (matches) {
hasAtLeastOneMatch = true;
break;
}
} catch (IllegalArgumentException ignored) {
// the provided header was not valid
}
}
if (!hasAtLeastOneMatch) {
throw new NotAcceptableException(INVALID_ACCEPT_HEADER_MESSAGE);
}
}

// cheating: would like to see how far we can go without doing anything here!
requestContext.setProducesChecked(true);
}

Expand Down

0 comments on commit 483a24f

Please sign in to comment.