From b3d502863e620c6e8861e15c9ea4a5d88105e184 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Thu, 9 Sep 2021 15:28:31 +0300 Subject: [PATCH] Loosen restriction on casing of the `Accept` header Fixes: #20021 --- .../server/handlers/FixedProducesHandler.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/FixedProducesHandler.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/FixedProducesHandler.java index 0e618046c034b..579550e43eefe 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/FixedProducesHandler.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/FixedProducesHandler.java @@ -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; @@ -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()); + } } } }