Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit88d582e

Browse files
carryelslandelle
authored andcommitted
Fixed "Sometimes multipart body missed last 1 byte."AsyncHttpClient#1271 and added the testcase. (AsyncHttpClient#1275)
1 parentda4e4af commit88d582e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

‎src/main/java/com/ning/http/client/multipart/MultipartBody.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public long read(ByteBuffer buffer) throws IOException {
183183
}
184184

185185
privatebooleancurrentBytesFullyRead() {
186-
returncurrentBytes ==null ||currentBytesPosition>=currentBytes.length -1;
186+
returncurrentBytes ==null ||currentBytesPosition== -1;
187187
}
188188

189189
privatevoidinitializeFileBody(AbstractFilePartpart)throwsIOException {

‎src/test/java/com/ning/http/client/multipart/MultipartBodyTest.java‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ public void transferWithCopy() throws IOException {
4040
}
4141
}
4242

43+
@Test
44+
publicvoidtransferWithCopy2()throwsIOException {
45+
try (finalMultipartBodymultipartBody =buildMultipart()) {
46+
finallongcontentLength =multipartBody.getContentLength();
47+
finalintbufferSize = (int)contentLength -1;
48+
finallongtranferred =transferWithCopy(multipartBody,bufferSize);
49+
Assert.assertEquals(tranferred,contentLength);
50+
}
51+
}
52+
4353
@Test
4454
publicvoidtransferZeroCopy()throwsIOException {
4555
try (MultipartBodymultipartBody =buildMultipart()) {
@@ -70,8 +80,11 @@ private static File getTestfile() {
7080
}
7181

7282
privatestaticlongtransferWithCopy(MultipartBodymultipartBody)throwsIOException {
83+
returntransferWithCopy(multipartBody,8192);
84+
}
7385

74-
finalByteBufferbuffer =ByteBuffer.allocate(8192);
86+
privatestaticlongtransferWithCopy(MultipartBodymultipartBody,intbufferSize)throwsIOException {
87+
finalByteBufferbuffer =ByteBuffer.allocate(bufferSize);
7588
longtotalBytes =0;
7689
while (true) {
7790
longreadBytes =multipartBody.read(buffer);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp