From ac9625c0aa73d6f63eb826a1fbbe135054707d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20W=C3=B3jcik?= Date: Wed, 15 Sep 2021 17:42:37 +0200 Subject: [PATCH] Add support for GraalVM ResourceURLConnection GraalVM native-image produces the binary with embedded resources from jar:. The protocol is then substituted to resource:. --- ring-core/src/ring/util/response.clj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ring-core/src/ring/util/response.clj b/ring-core/src/ring/util/response.clj index a638f7a27..d38914e46 100644 --- a/ring-core/src/ring/util/response.clj +++ b/ring-core/src/ring/util/response.clj @@ -289,6 +289,14 @@ (if-not (zero? last-mod) (Date. last-mod)))) +(defmethod resource-data :resource + [^java.net.URL url] + ;; GraalVM resource scheme + (let [resource (.openConnection url)] + {:content (.getInputStream resource) + :content-length (connection-content-length resource) + :last-modified (connection-last-modified resource)})) + (defmethod resource-data :jar [^java.net.URL url] (let [conn (.openConnection url)]