@Test public void testLinkPreload() throws Exception { List<Http2PushMapping> mappings = new ArrayList<>(); mappings.add(new Http2PushMapping("style.css", "style", false)); mappings.add(new Http2PushMapping("coin.png", "image", false)); stat.setHttp2PushMapping(mappings) .setWebRoot("webroot/somedir3"); testRequest(HttpMethod.GET, "/testLinkPreload.html", null, res -> { List<String> linkHeaders = res.headers().getAll("Link"); assertTrue(linkHeaders.contains("<style.css>; rel=preload; as=style")); assertTrue(linkHeaders.contains("<coin.png>; rel=preload; as=image")); }, 200, "OK", null); }
/** * Set the file mapping for http2push and link preload * @param http2PushMappings the mapping for http2 push * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.StaticHandler setHttp2PushMapping(List<Http2PushMapping> http2PushMappings) { delegate.setHttp2PushMapping(http2PushMappings); return this; }
/** * Set the file mapping for http2push and link preload * @param http2PushMappings the mapping for http2 push * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.StaticHandler setHttp2PushMapping(List<Http2PushMapping> http2PushMappings) { delegate.setHttp2PushMapping(http2PushMappings); return this; }
mappings.add(new Http2PushMapping("style.css", "style", false)); mappings.add(new Http2PushMapping("coin.png", "image", false)); stat.setHttp2PushMapping(mappings) .setWebRoot("webroot/somedir3"); router.route().handler(stat);
public static io.vertx.ext.web.handler.StaticHandler setHttp2PushMapping(io.vertx.ext.web.handler.StaticHandler j_receiver, java.util.List<java.util.Map<String, Object>> http2PushMappings) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.setHttp2PushMapping(http2PushMappings != null ? http2PushMappings.stream().map(elt -> elt != null ? new io.vertx.ext.web.Http2PushMapping(io.vertx.core.impl.ConversionHelper.toJsonObject(elt)) : null).collect(java.util.stream.Collectors.toList()) : null)); return j_receiver; } }
@Test public void testLinkPreload() throws Exception { List<Http2PushMapping> mappings = new ArrayList<>(); mappings.add(new Http2PushMapping("style.css", "style", false)); mappings.add(new Http2PushMapping("coin.png", "image", false)); stat.setHttp2PushMapping(mappings) .setWebRoot("webroot/somedir3"); testRequest(HttpMethod.GET, "/testLinkPreload.html", null, res -> { List<String> linkHeaders = res.headers().getAll("Link"); assertTrue(linkHeaders.contains("<style.css>; rel=preload; as=style")); assertTrue(linkHeaders.contains("<coin.png>; rel=preload; as=image")); }, 200, "OK", null); }
mappings.add(new Http2PushMapping("style.css", "style", false)); mappings.add(new Http2PushMapping("coin.png", "image", false)); stat.setHttp2PushMapping(mappings) .setWebRoot("webroot/somedir3"); router.route().handler(stat);