Skip to content

Commit

Permalink
Merge pull request quarkusio#37646 from geoand/quarkusio#37637
Browse files Browse the repository at this point in the history
Remove unnecessary content type checks
  • Loading branch information
geoand authored Dec 11, 2023
2 parents 6971f07 + d25df94 commit 9d9cb79
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 9d9cb79

Please sign in to comment.