Skip to content

Commit

Permalink
HttpServerFileUpload should be resumed when the pending inbound buffe…
Browse files Browse the repository at this point in the history
…r is drained - fixes #2736
  • Loading branch information
vietj committed Nov 28, 2018
1 parent b9a934e commit cdc8172
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Expand Up @@ -63,6 +63,7 @@ class HttpServerFileUploadImpl implements HttpServerFileUpload {
this.charset = charset; this.charset = charset;
this.size = size; this.size = size;
this.pending = new InboundBuffer<Buffer>(context) this.pending = new InboundBuffer<Buffer>(context)
.drainHandler(v -> req.resume())
.emptyHandler(v -> { .emptyHandler(v -> {
if (complete) { if (complete) {
handleComplete(); handleComplete();
Expand Down
16 changes: 13 additions & 3 deletions src/test/java/io/vertx/core/http/HttpTest.java
Expand Up @@ -2733,18 +2733,28 @@ public void testFormUploadSmallFile() throws Exception {
} }


@Test @Test
public void testFormUploadLargerFile() throws Exception { public void testFormUploadMediumFile() throws Exception {
testFormUploadFile(TestUtils.randomAlphaString(20000), false); testFormUploadFile(TestUtils.randomAlphaString(20000), false);
} }


@Test
public void testFormUploadLargeFile() throws Exception {
testFormUploadFile(TestUtils.randomAlphaString(4 * 1024 * 1024), false);
}

@Test @Test
public void testFormUploadSmallFileStreamToDisk() throws Exception { public void testFormUploadSmallFileStreamToDisk() throws Exception {
testFormUploadFile(TestUtils.randomAlphaString(100), true); testFormUploadFile(TestUtils.randomAlphaString(100), true);
} }


@Test @Test
public void testFormUploadLargerFileStreamToDisk() throws Exception { public void testFormUploadMediumFileStreamToDisk() throws Exception {
testFormUploadFile(TestUtils.randomAlphaString(20000), true); testFormUploadFile(TestUtils.randomAlphaString(20 * 1024), true);
}

@Test
public void testFormUploadLargeFileStreamToDisk() throws Exception {
testFormUploadFile(TestUtils.randomAlphaString(4 * 1024 * 1024), true);
} }


private void testFormUploadFile(String contentStr, boolean streamToDisk) throws Exception { private void testFormUploadFile(String contentStr, boolean streamToDisk) throws Exception {
Expand Down

0 comments on commit cdc8172

Please sign in to comment.