|
24 | 24 | import io.vertx.core.http.impl.headers.HeadersMultiMap; |
25 | 25 | import io.vertx.core.impl.SysProps; |
26 | 26 | import io.vertx.core.internal.ContextInternal; |
27 | | -import io.vertx.core.impl.Utils; |
28 | 27 | import io.vertx.core.internal.VertxInternal; |
29 | 28 | import io.vertx.core.internal.http.HttpServerRequestInternal; |
30 | 29 | import io.vertx.core.json.JsonArray; |
|
41 | 40 | import org.junit.Ignore; |
42 | 41 | import org.junit.Test; |
43 | 42 |
|
44 | | -import java.io.File; |
45 | 43 | import java.util.*; |
46 | 44 | import java.util.concurrent.*; |
47 | 45 | import java.util.concurrent.atomic.AtomicBoolean; |
@@ -3787,29 +3785,6 @@ private void testPerXXXPooling(Function<Integer, Future<HttpClientRequest>> requ |
3787 | 3785 | await(); |
3788 | 3786 | } |
3789 | 3787 |
|
3790 | | - @Test |
3791 | | - public void testSendFileFailsWhenClientClosesConnection() throws Exception { |
3792 | | - // 10 megs |
3793 | | - final File f = setupFile("file.pdf", TestUtils.randomUnicodeString(10 * 1024 * 1024)); |
3794 | | - server.requestHandler(req -> { |
3795 | | - try { |
3796 | | - req.response().sendFile(f.getAbsolutePath()).onComplete(onFailure(err -> { |
3797 | | - // Broken pipe |
3798 | | - testComplete(); |
3799 | | - })); |
3800 | | - } catch (Exception e) { |
3801 | | - // this was the bug reported with issues/issue-80 |
3802 | | - fail(e); |
3803 | | - } |
3804 | | - }); |
3805 | | - startServer(testAddress); |
3806 | | - vertx.createNetClient().connect(testAddress).onComplete(onSuccess(socket -> { |
3807 | | - socket.write("GET / HTTP/1.1\r\n\r\n"); |
3808 | | - socket.close(); |
3809 | | - })); |
3810 | | - await(); |
3811 | | - } |
3812 | | - |
3813 | 3788 | // Use a raw socket to check the body response is effectively empty (it could be an empty chunk) |
3814 | 3789 | protected MultiMap checkEmptyHttpResponse(HttpMethod method, int sc, MultiMap reqHeaders) throws Exception { |
3815 | 3790 | server.requestHandler(req -> { |
@@ -4870,82 +4845,6 @@ public void start(Promise<Void> startFuture) { |
4870 | 4845 | await(); |
4871 | 4846 | } |
4872 | 4847 |
|
4873 | | - @Test |
4874 | | - public void testHttpServerWithIdleTimeoutSendChunkedFile() throws Exception { |
4875 | | - // Does not pass reliably in CI (timeout) |
4876 | | - Assume.assumeTrue(!vertx.isNativeTransportEnabled() && !Utils.isWindows()); |
4877 | | - int expected = 32 * 1024 * 1024; |
4878 | | - File file = TestUtils.tmpFile(".dat", expected); |
4879 | | - // Estimate the delay to transfer a file with a 1ms pause in chunks |
4880 | | - int delay = retrieveFileFromServer(file, createBaseServerOptions()); |
4881 | | - // Now test with timeout relative to this delay |
4882 | | - int timeout = delay / 2; |
4883 | | - delay = retrieveFileFromServer(file, createBaseServerOptions().setIdleTimeout(timeout).setIdleTimeoutUnit(TimeUnit.MILLISECONDS)); |
4884 | | - assertTrue(delay > timeout); |
4885 | | - } |
4886 | | - |
4887 | | - private int retrieveFileFromServer(File file, HttpServerOptions options) throws Exception { |
4888 | | - server.close().await(); |
4889 | | - server = vertx |
4890 | | - .createHttpServer(options) |
4891 | | - .requestHandler( |
4892 | | - req -> { |
4893 | | - req.response().sendFile(file.getAbsolutePath()); |
4894 | | - }); |
4895 | | - startServer(testAddress); |
4896 | | - long now = System.currentTimeMillis(); |
4897 | | - Integer len = getFile().await(); |
4898 | | - assertEquals((int)len, file.length()); |
4899 | | - return (int) (System.currentTimeMillis() - now); |
4900 | | - } |
4901 | | - |
4902 | | - private Future<Integer> getFile() { |
4903 | | - int[] length = {0}; |
4904 | | - return client.request(requestOptions) |
4905 | | - .compose(req -> req.send() |
4906 | | - .compose(resp -> { |
4907 | | - resp.handler(buff -> { |
4908 | | - length[0] += buff.length(); |
4909 | | - resp.pause(); |
4910 | | - vertx.setTimer(1, id -> { |
4911 | | - resp.resume(); |
4912 | | - }); |
4913 | | - }); |
4914 | | - resp.exceptionHandler(this::fail); |
4915 | | - return resp.end(); |
4916 | | - })) |
4917 | | - .map(v -> length[0]); |
4918 | | - } |
4919 | | - |
4920 | | - @Test |
4921 | | - public void testSendFilePipelined() throws Exception { |
4922 | | - int n = 2; |
4923 | | - waitFor(n); |
4924 | | - File sent = TestUtils.tmpFile(".dat", 16 * 1024); |
4925 | | - server.requestHandler( |
4926 | | - req -> { |
4927 | | - req.response().sendFile(sent.getAbsolutePath()); |
4928 | | - }); |
4929 | | - startServer(testAddress); |
4930 | | - client.close(); |
4931 | | - client = vertx.createHttpClient(createBaseClientOptions().setPipelining(true), new PoolOptions().setHttp1MaxSize(1)); |
4932 | | - for (int i = 0;i < n;i++) { |
4933 | | - client.request(requestOptions) |
4934 | | - .compose(req -> req.send().compose(HttpClientResponse::body)) |
4935 | | - .onComplete(onSuccess(body -> { |
4936 | | - complete(); |
4937 | | - })); |
4938 | | - } |
4939 | | - await(); |
4940 | | - } |
4941 | | - |
4942 | | - @Test |
4943 | | - public void testSendFileWithConnectionCloseHeader() throws Exception { |
4944 | | - String content = TestUtils.randomUnicodeString(1024 * 1024 * 2); |
4945 | | - sendFile("test-send-file.html", content, false, |
4946 | | - () -> client.request(requestOptions).map(req -> req.putHeader(HttpHeaders.CONNECTION, "close"))); |
4947 | | - } |
4948 | | - |
4949 | 4848 | @Test |
4950 | 4849 | public void testResponseEndHandlersConnectionClose() throws Exception { |
4951 | 4850 | waitFor(2); |
|
0 commit comments