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: #37637
  • Loading branch information
geoand committed Dec 11, 2023
1 parent f7ce12b commit d25df94
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public abstract class ResteasyReactiveRequestContext
private OutputStream outputStream;
private OutputStream underlyingOutputStream;
private FormData formData;
private boolean producesChecked;

public ResteasyReactiveRequestContext(Deployment deployment,
ThreadSetupAction requestContext, ServerRestHandler[] handlerChain, ServerRestHandler[] abortHandlerChain) {
Expand Down Expand Up @@ -796,6 +797,14 @@ public void initPathSegments() {
}
}

public void setProducesChecked(boolean checked) {
producesChecked = checked;
}

public boolean isProducesChecked() {
return producesChecked;
}

@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 d25df94

Please sign in to comment.