Skip to content

Commit

Permalink
Merge pull request #20026 from geoand/#20021
Browse files Browse the repository at this point in the history
Loosen restriction on casing of the `Accept` header
  • Loading branch information
geoand authored Sep 20, 2021
2 parents e5b4d79 + b3d5028 commit 879c866
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jboss.resteasy.reactive.server.handlers;

import java.util.Locale;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
Expand Down Expand Up @@ -40,8 +41,15 @@ public void handle(ResteasyReactiveRequestContext requestContext) throws Excepti
requestContext.setResponseContentType(mediaType);
requestContext.setEntityWriter(writer);
} else {
throw new WebApplicationException(
Response.notAcceptable(Variant.mediaTypes(mediaType.getMediaType()).build()).build());
// some clients might be sending the header with incorrect casing...
String lowercaseAccept = accept.toLowerCase(Locale.ROOT);
if (lowercaseAccept.contains(mediaTypeString) || lowercaseAccept.contains(mediaTypeSubstring)) {
requestContext.setResponseContentType(mediaType);
requestContext.setEntityWriter(writer);
} else {
throw new WebApplicationException(
Response.notAcceptable(Variant.mediaTypes(mediaType.getMediaType()).build()).build());
}
}
}
}
Expand Down

0 comments on commit 879c866

Please sign in to comment.