Class KiwiResponses2
java.lang.Object
org.kiwiproject.beta.jakarta.rest.KiwiResponses2
Utilities related to Jakarta REST
Response.
Some of these methods eventually may be moved into org.kiwiproject.jaxrs.KiwiResponses
in kiwi.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringhtmlEscapeEntity(jakarta.ws.rs.core.Response response) If theResponseis HTML, return the escaped entity.
-
Method Details
-
htmlEscapeEntity
If theResponseis 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
Responsewhen reading the entity as a String.Note: The
responsemust not be closed, and the entity cannot have already been read. These are transitive restrictions from thereadEntitymethod, which is used to read the entity. AnIllegalStateExceptionis thrown if either of these restrictions is violated. Also note that the response will be closed after this method returns, again because ofreadEntity.- Parameters:
response- theResponsefrom which to read and escape the entity- Returns:
- the HTML-escaped entity if the response is HTML, otherwise the original entity
- Throws:
IllegalArgumentException- ifresponseis nullIllegalStateException- if theresponseis closed or the entity has already been consumed- See Also:
-
Response.readEntity(Class)
-