HttpServerResponse resp = req.response(); if ("/".equals(path)) { resp.push(HttpMethod.GET, "/script.js", ar -> { if (ar.succeeded()) { System.out.println("sending push");
@Test public void testResetPushPromiseNoHandler() throws Exception { server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/wibble", ar -> { assertTrue(ar.succeeded()); HttpServerResponse resp = ar.result(); resp.setChunked(true).write("content"); AtomicLong reset = new AtomicLong(); resp.exceptionHandler(err -> { if (err instanceof StreamResetException) { reset.set(((StreamResetException)err).getCode()); } }); resp.closeHandler(v -> { assertEquals(Http2Error.CANCEL.code(), reset.get()); testComplete(); }); }); }); startServer(); HttpClientRequest req = client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> { }); req.end(); await(); }
waitFor(2); server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/wibble?a=b", ar -> { assertTrue(ar.succeeded()); HttpServerResponse response = ar.result();
@Test public void testResetPendingPushPromise() throws Exception { server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/wibble", ar -> { assertFalse(ar.succeeded()); testComplete(); }); }); startServer(); client.close(); client = vertx.createHttpClient(clientOptions.setInitialSettings(new io.vertx.core.http.Http2Settings().setMaxConcurrentStreams(0L))); HttpClientRequest req = client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", onFailure(resp -> {})); req.pushHandler(pushedReq -> { pushedReq.reset(Http2Error.CANCEL.code()); }); req.end(); await(); }
@Test public void testResetActivePushPromise() throws Exception { server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/wibble", ar -> { assertTrue(ar.succeeded()); HttpServerResponse response = ar.result(); response.exceptionHandler(err -> { if (err instanceof StreamResetException) { assertEquals(Http2Error.CANCEL.code(), ((StreamResetException) err).getCode()); testComplete(); } }); response.setChunked(true).write("some_content"); }); }); startServer(); HttpClientRequest req = client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", onFailure(resp -> { })); req.pushHandler(pushedReq -> { pushedReq.handler(onSuccess(pushedResp -> { pushedResp.handler(buff -> { pushedReq.reset(Http2Error.CANCEL.code()); }); })); }); req.end(); await(); }
int contentLength = numBuffers * 1000; server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/wibble", ar -> { HttpServerResponse pushedResp = ar.result(); FakeHttpServerMetrics serverMetrics = FakeMetricsBase.getMetrics(server);
waitFor(4); server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/pushpath", ar -> { assertTrue(ar.succeeded()); HttpServerResponse pushedResp = ar.result();
waitFor(4); server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/pushpath", ar -> { assertTrue(ar.succeeded()); HttpServerResponse pushedResp = ar.result();
/** * Like {@link io.vertx.rxjava.core.http.HttpServerResponse#push} with the host copied from the current request. * @param method * @param path * @param handler * @return */ public io.vertx.rxjava.core.http.HttpServerResponse push(HttpMethod method, String path, Handler<AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>> handler) { delegate.push(method, path, new Handler<AsyncResult<io.vertx.core.http.HttpServerResponse>>() { public void handle(AsyncResult<io.vertx.core.http.HttpServerResponse> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.http.HttpServerResponse.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
/** * Like {@link io.vertx.rxjava.core.http.HttpServerResponse#push} with the host copied from the current request. * @param method * @param path * @param handler * @return */ public io.vertx.rxjava.core.http.HttpServerResponse push(HttpMethod method, String path, Handler<AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>> handler) { delegate.push(method, path, new Handler<AsyncResult<io.vertx.core.http.HttpServerResponse>>() { public void handle(AsyncResult<io.vertx.core.http.HttpServerResponse> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.http.HttpServerResponse.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
response.push(HttpMethod.GET, "/" + dependency.getFilePath(), pushAsyncResult -> { if (pushAsyncResult.succeeded()) { HttpServerResponse res = pushAsyncResult.result();
/** * Like {@link io.vertx.rxjava.core.http.HttpServerResponse#push} with no headers. * @param method * @param host * @param path * @param handler * @return */ public io.vertx.rxjava.core.http.HttpServerResponse push(HttpMethod method, String host, String path, Handler<AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>> handler) { delegate.push(method, host, path, new Handler<AsyncResult<io.vertx.core.http.HttpServerResponse>>() { public void handle(AsyncResult<io.vertx.core.http.HttpServerResponse> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.http.HttpServerResponse.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
@Test public void testResetPushPromiseNoHandler() throws Exception { server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/wibble", ar -> { assertTrue(ar.succeeded()); HttpServerResponse resp = ar.result(); resp.setChunked(true).write("content"); AtomicLong reset = new AtomicLong(); resp.exceptionHandler(err -> { if (err instanceof StreamResetException) { reset.set(((StreamResetException)err).getCode()); } }); resp.closeHandler(v -> { assertEquals(Http2Error.CANCEL.code(), reset.get()); testComplete(); }); }); }); startServer(); HttpClientRequest req = client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> { }); req.end(); await(); }
waitFor(2); server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/wibble?a=b", ar -> { assertTrue(ar.succeeded()); HttpServerResponse response = ar.result();
@Test public void testResetPendingPushPromise() throws Exception { server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/wibble", ar -> { assertFalse(ar.succeeded()); testComplete(); }); }); startServer(); client.close(); client = vertx.createHttpClient(clientOptions.setInitialSettings(new io.vertx.core.http.Http2Settings().setMaxConcurrentStreams(0L))); HttpClientRequest req = client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> { fail(); }); req.pushHandler(pushedReq -> { pushedReq.reset(Http2Error.CANCEL.code()); }); req.end(); await(); }
/** * Like {@link io.vertx.rxjava.core.http.HttpServerResponse#push} with the host copied from the current request. * @param method * @param path * @param headers * @param handler * @return */ public io.vertx.rxjava.core.http.HttpServerResponse push(HttpMethod method, String path, io.vertx.rxjava.core.MultiMap headers, Handler<AsyncResult<io.vertx.rxjava.core.http.HttpServerResponse>> handler) { delegate.push(method, path, headers.getDelegate(), new Handler<AsyncResult<io.vertx.core.http.HttpServerResponse>>() { public void handle(AsyncResult<io.vertx.core.http.HttpServerResponse> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.http.HttpServerResponse.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
@Test public void testResetActivePushPromise() throws Exception { server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/wibble", ar -> { assertTrue(ar.succeeded()); HttpServerResponse response = ar.result(); response.exceptionHandler(err -> { if (err instanceof StreamResetException) { assertEquals(Http2Error.CANCEL.code(), ((StreamResetException) err).getCode()); testComplete(); } }); response.setChunked(true).write("some_content"); }); }); startServer(); HttpClientRequest req = client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> { fail(); }); req.pushHandler(pushedReq -> { pushedReq.handler(pushedResp -> { pushedResp.handler(buff -> { pushedReq.reset(Http2Error.CANCEL.code()); }); }); }); req.end(); await(); }
waitFor(4); server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/pushpath", ar -> { assertTrue(ar.succeeded()); HttpServerResponse pushedResp = ar.result();
waitFor(4); server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/pushpath", ar -> { assertTrue(ar.succeeded()); HttpServerResponse pushedResp = ar.result();
int contentLength = numBuffers * 1000; server.requestHandler(req -> { req.response().push(HttpMethod.GET, "/wibble", ar -> { HttpServerResponse pushedResp = ar.result(); FakeHttpServerMetrics serverMetrics = FakeMetricsBase.getMetrics(server);