Skip to content

Commit

Permalink
Remove unnecessary content type checks
Browse files Browse the repository at this point in the history
These checks have potentially already
been performed in ClassRoutingHandler

Closes: quarkusio#37637
  • Loading branch information
geoand committed Dec 11, 2023
1 parent 8cfaa73 commit f070cb8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,18 @@ public void initPathSegments() {
}
}

private static final String PRODUCES_CHECKED_PROPERTY_KEY = AbstractResteasyReactiveContext.CUSTOM_RR_PROPERTIES_PREFIX
+ "ProducesChecked";

public void setProducesChecked(boolean checked) {
setProperty(PRODUCES_CHECKED_PROPERTY_KEY, checked);
}

public boolean isProducesChecked() {
Object val = getProperty(PRODUCES_CHECKED_PROPERTY_KEY);
return val != null && (boolean) val;
}

@Override
public Object getHeader(String name, boolean single) {
if (httpHeaders == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public void handle(ResteasyReactiveRequestContext requestContext) throws Excepti
throw new NotAcceptableException(INVALID_ACCEPT_HEADER_MESSAGE);
}
}

requestContext.setProducesChecked(true);
}

requestContext.restart(target.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public FixedProducesHandler(MediaType mediaType, EntityWriter writer) {
@Override
public void handle(ResteasyReactiveRequestContext requestContext) throws Exception {
List<String> acceptValues = (List<String>) requestContext.getHeader(HttpHeaders.ACCEPT, false);
if (acceptValues.isEmpty()) {
if (acceptValues.isEmpty() || requestContext.isProducesChecked()) {
requestContext.setResponseContentType(mediaType);
requestContext.setEntityWriter(writer);
} else {
Expand Down

0 comments on commit f070cb8

Please sign in to comment.