/** * Reset this HTTP/2 stream with the error {@code code}. * * @param code the error code */ void reset(long code);
/** * Reset this HTTP/2 stream with the error {@code code}. * * @param code the error code */ void reset(long code);
@Test public void testServerResponseResetFromOtherThread() throws Exception { waitFor(2); server.requestHandler(req -> { runAsync(() -> { req.response().reset(0); }); }).listen(onSuccess(v -> { client.get(8080, "localhost", "/somepath", onFailure(err -> { assertTrue(err instanceof StreamResetException); complete(); })).exceptionHandler(err -> { assertTrue(err instanceof StreamResetException); complete(); }).sendHead(); })); await(); }
@Test public void testServerResetClientStreamDuringRequest() throws Exception { String chunk = TestUtils.randomAlphaString(1024); server.requestHandler(req -> { req.handler(buf -> { req.response().reset(8); }); }); startServer(); client.post(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", onFailure(resp -> {})) .exceptionHandler(err -> { Context ctx = Vertx.currentContext(); assertOnIOContext(ctx); assertTrue(err instanceof StreamResetException); StreamResetException reset = (StreamResetException) err; assertEquals(8, reset.getCode()); testComplete(); }).setChunked(true).write(chunk); await(); }
@Test public void testServerResetClientStreamDuringResponse() throws Exception { waitFor(2); String chunk = TestUtils.randomAlphaString(1024); Future<Void> doReset = Future.future(); server.requestHandler(req -> { doReset.setHandler(onSuccess(v -> { req.response().reset(8); })); req.response().setChunked(true).write(Buffer.buffer(chunk)); }); startServer(); Context ctx = vertx.getOrCreateContext(); Handler<Throwable> resetHandler = err -> { assertOnIOContext(ctx); assertTrue(err instanceof StreamResetException); StreamResetException reset = (StreamResetException) err; assertEquals(8, reset.getCode()); complete(); }; ctx.runOnContext(v -> { client.post(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", onSuccess(resp -> { resp.exceptionHandler(resetHandler); resp.handler(buff -> { doReset.complete(); }); })).exceptionHandler(resetHandler).setChunked(true).write(chunk); }); await(); }
/** * Reset this HTTP/2 stream with the error code <code>0</code>. */ public void reset() { delegate.reset(); }
/** * Reset this HTTP/2 stream with the error <code>code</code>. * @param code the error code */ public void reset(long code) { delegate.reset(code); }
/** * Reset this HTTP/2 stream with the error <code>code</code>. * @param code the error code */ public void reset(long code) { delegate.reset(code); }
/** * Reset this HTTP/2 stream with the error code <code>0</code>. */ public void reset() { delegate.reset(); }
@Test public void testServerResponseResetFromOtherThread() throws Exception { server.requestHandler(req -> { runAsync(() -> { req.response().reset(0); }); }).listen(onSuccess(v -> { client.get(8080, "localhost", "/somepath", resp -> { fail(); }).exceptionHandler(err -> { assertTrue(err instanceof StreamResetException); testComplete(); }).sendHead(); })); await(); }
@Test public void testServerResetClientStreamDuringRequest() throws Exception { String chunk = TestUtils.randomAlphaString(1024); server.requestHandler(req -> { req.handler(buf -> { req.response().reset(8); }); }); startServer(); client.post(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> { fail(); }).exceptionHandler(err -> { Context ctx = Vertx.currentContext(); assertOnIOContext(ctx); assertTrue(err instanceof StreamResetException); StreamResetException reset = (StreamResetException) err; assertEquals(8, reset.getCode()); testComplete(); }).setChunked(true).write(chunk); await(); }
@Test public void testServerResetClientStreamDuringResponse() throws Exception { waitFor(2); String chunk = TestUtils.randomAlphaString(1024); Future<Void> doReset = Future.future(); server.requestHandler(req -> { doReset.setHandler(onSuccess(v -> { req.response().reset(8); })); req.response().setChunked(true).write(Buffer.buffer(chunk)); }); startServer(); Context ctx = vertx.getOrCreateContext(); Handler<Throwable> resetHandler = err -> { assertOnIOContext(ctx); assertTrue(err instanceof StreamResetException); StreamResetException reset = (StreamResetException) err; assertEquals(8, reset.getCode()); complete(); }; ctx.runOnContext(v -> { client.post(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> { resp.exceptionHandler(resetHandler); resp.handler(buff -> { doReset.complete(); }); }).exceptionHandler(resetHandler).setChunked(true).write(chunk); }); await(); }