| | |
| | | import org.jboss.resteasy.spi.HttpRequest; |
| | | import org.keycloak.protocol.cas.CASLoginProtocol; |
| | | |
| | | import javax.ws.rs.BadRequestException; |
| | | import javax.ws.rs.core.*; |
| | | |
| | | public class ContentTypeHelper { |
| | |
| | | //if parameter is set, it overrides all header values (see spec section 2.5.1) |
| | | request.getMutableHeaders().putSingle(HttpHeaders.ACCEPT, "application/" + format.toLowerCase()); |
| | | } |
| | | Variant variant = restRequest.selectVariant(Variant.mediaTypes(MediaType.APPLICATION_XML_TYPE, MediaType.APPLICATION_JSON_TYPE).build()); |
| | | return variant == null ? MediaType.APPLICATION_XML_TYPE : variant.getMediaType(); |
| | | try { |
| | | Variant variant = restRequest.selectVariant(Variant.mediaTypes(MediaType.APPLICATION_XML_TYPE, MediaType.APPLICATION_JSON_TYPE).build()); |
| | | return variant == null ? MediaType.APPLICATION_XML_TYPE : variant.getMediaType(); |
| | | } catch (BadRequestException e) { |
| | | //the default Accept header set by java.net.HttpURLConnection is invalid (cf. RESTEASY-960) |
| | | return MediaType.APPLICATION_XML_TYPE; |
| | | } |
| | | } |
| | | } |