diff --git a/bom/application/pom.xml b/bom/application/pom.xml
index 45bc122623fee..4cfc187c32ae1 100644
--- a/bom/application/pom.xml
+++ b/bom/application/pom.xml
@@ -225,8 +225,8 @@
3.0.0
2.12.3
- 1.0.9
- 24.1.4
+ 1.0.10
+ 24.1.6
2.8.0
3.3.3
2.8.0
diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/MvnpmHandler.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/MvnpmHandler.java
index 5d68e31d9c382..6b5a7d961fe56 100644
--- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/MvnpmHandler.java
+++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/MvnpmHandler.java
@@ -5,6 +5,13 @@
import java.io.UncheckedIOException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.net.URLConnection;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAccessor;
+import java.util.Locale;
import java.util.Set;
import io.vertx.core.Handler;
@@ -22,7 +29,7 @@ public class MvnpmHandler implements Handler {
public MvnpmHandler(String root, Set mvnpmJars) {
this.root = root;
- this.mvnpmLoader = new URLClassLoader(mvnpmJars.toArray(new URL[] {}));
+ this.mvnpmLoader = new URLClassLoader(mvnpmJars.toArray(URL[]::new));
}
@Override
@@ -37,13 +44,20 @@ public void handle(RoutingContext event) {
}
try {
- InputStream is = mvnpmLoader.getResourceAsStream(BASE_DIR + fullPath);
- if (is != null) {
- byte[] contents = is.readAllBytes();
- event.response()
- .putHeader(HttpHeaders.CONTENT_TYPE, getContentType(fileName))
- .end(Buffer.buffer(contents));
- return;
+ URL url = mvnpmLoader.getResource(BASE_DIR + fullPath);
+ URLConnection openConnection = url.openConnection();
+ long lastModified = openConnection.getLastModified();
+ try (InputStream is = openConnection.getInputStream()) {
+ if (is != null) {
+ byte[] contents = is.readAllBytes();
+ event.response()
+ .putHeader(HttpHeaders.CONTENT_TYPE, getContentType(fileName))
+ .putHeader(HttpHeaders.CACHE_CONTROL, "public, immutable, max-age=31536000")
+ .putHeader(HttpHeaders.LAST_MODIFIED, formatDate(lastModified))
+ .putHeader("date", formatDate(LocalDateTime.now()))
+ .end(Buffer.buffer(contents));
+ return;
+ }
}
} catch (IOException ex) {
throw new UncheckedIOException(ex);
@@ -51,6 +65,17 @@ public void handle(RoutingContext event) {
event.next();
}
+ private String formatDate(long m) {
+ Instant i = Instant.ofEpochMilli(m);
+ return formatDate(i);
+ }
+
+ private String formatDate(TemporalAccessor t) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH)
+ .withZone(ZoneId.of("GMT"));
+ return formatter.format(t);
+ }
+
private String getContentType(String filename) {
String f = filename.toLowerCase();
if (f.endsWith(DOT_JS)) {