Class KiwiResponses2

java.lang.Object
org.kiwiproject.beta.jakarta.rest.KiwiResponses2

@Beta public final class KiwiResponses2 extends Object
Utilities related to Jakarta REST Response.

Some of these methods eventually may be moved into org.kiwiproject.jaxrs.KiwiResponses in kiwi.

  • Method Details

    • htmlEscapeEntity

      public static String htmlEscapeEntity(jakarta.ws.rs.core.Response response)
      If the Response is HTML, return the escaped entity. Otherwise, return the original response entity.

      If the response has no entity, an empty string is returned to be consistent with the behavior of Response when reading the entity as a String.

      Note: The response must not be closed, and the entity cannot have already been read. These are transitive restrictions from the readEntity method, which is used to read the entity. An IllegalStateException is thrown if either of these restrictions is violated. Also note that the response will be closed after this method returns, again because of readEntity.

      Parameters:
      response - the Response from which to read and escape the entity
      Returns:
      the HTML-escaped entity if the response is HTML, otherwise the original entity
      Throws:
      IllegalArgumentException - if response is null
      IllegalStateException - if the response is closed or the entity has already been consumed
      See Also:
      • Response.readEntity(Class)