Introduce Response.isClosed() method with default impl.

Signed-off-by: Nicolas NESMON (NicoNes) <nicolas.nesmon@gmail.com>
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Response.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Response.java
index 82e85d7..5d3c1b9 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Response.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Response.java
@@ -464,6 +464,22 @@
     public abstract String getHeaderString(String name);
 
     /**
+     * Check if the response is closed. The method returns {@code true} if the response is closed,
+     * returns {@code false} otherwise.
+     *
+     * @return {@code true} if the response has been {@link #close() closed}, {@code false} otherwise.
+     * @since 3.1
+     */
+    public boolean isClosed() {
+        try {
+            hasEntity();
+            return false;
+        } catch (IllegalStateException ignored) {
+            return true;
+        }
+    }
+
+    /**
      * Create a new ResponseBuilder by performing a shallow copy of an existing Response.
      * <p>
      * The returned builder has its own {@link #getHeaders() response headers} but the header values are shared with the