All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.resteasy.reactive.common.providers.serialisers.JsonMessageBodyWriterUtil Maven / Gradle / Ivy

There is a newer version: 3.17.0.CR1
Show newest version
package org.jboss.resteasy.reactive.common.providers.serialisers;

import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.MultivaluedMap;

public class JsonMessageBodyWriterUtil {
    public static void setContentTypeIfNecessary(MultivaluedMap httpHeaders) {
        Object contentType = httpHeaders.getFirst(HttpHeaders.CONTENT_TYPE);
        if (isNotJson(contentType)) {
            httpHeaders.putSingle(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
        }
    }

    public static boolean isNotJson(Object contentType) {
        return (contentType == null) || !contentType.toString().contains("json");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy