Skip to content

Commit 806670f

Browse files
committed
Add unknown-content-length coverage for large file uploads using InputStreamPart
1 parent 1a6c522 commit 806670f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

client/src/test/java/org/asynchttpclient/request/body/InputStreamPartLargeFileTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ public void testPutImageFile() throws Exception {
6868
}
6969
}
7070

71+
@Test
72+
public void testPutImageFileUnknownSize() throws Exception {
73+
try (AsyncHttpClient client = asyncHttpClient(config().setRequestTimeout(100 * 6000))) {
74+
InputStream inputStream = new BufferedInputStream(new FileInputStream(LARGE_IMAGE_FILE));
75+
Response response = client.preparePut(getTargetUrl()).addBodyPart(new InputStreamPart("test", inputStream, LARGE_IMAGE_FILE.getName(), -1, "application/octet-stream", UTF_8)).execute().get();
76+
assertEquals(response.getStatusCode(), 200);
77+
}
78+
}
79+
7180
@Test
7281
public void testPutLargeTextFile() throws Exception {
7382
File file = createTempFile(1024 * 1024);
@@ -79,4 +88,16 @@ public void testPutLargeTextFile() throws Exception {
7988
assertEquals(response.getStatusCode(), 200);
8089
}
8190
}
91+
92+
@Test
93+
public void testPutLargeTextFileUnknownSize() throws Exception {
94+
File file = createTempFile(1024 * 1024);
95+
InputStream inputStream = new BufferedInputStream(new FileInputStream(file));
96+
97+
try (AsyncHttpClient client = asyncHttpClient(config().setRequestTimeout(100 * 6000))) {
98+
Response response = client.preparePut(getTargetUrl())
99+
.addBodyPart(new InputStreamPart("test", inputStream, file.getName(), -1, "application/octet-stream", UTF_8)).execute().get();
100+
assertEquals(response.getStatusCode(), 200);
101+
}
102+
}
82103
}

0 commit comments

Comments
 (0)