File tree 2 files changed +15
-2
lines changed
main/java/com/ning/http/client/multipart
test/java/com/ning/http/client/multipart 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ public long read(ByteBuffer buffer) throws IOException {
183
183
}
184
184
185
185
private boolean currentBytesFullyRead () {
186
- return currentBytes == null || currentBytesPosition >= currentBytes . length - 1 ;
186
+ return currentBytes == null || currentBytesPosition == - 1 ;
187
187
}
188
188
189
189
private void initializeFileBody (AbstractFilePart part ) throws IOException {
Original file line number Diff line number Diff line change @@ -40,6 +40,16 @@ public void transferWithCopy() throws IOException {
40
40
}
41
41
}
42
42
43
+ @ Test
44
+ public void transferWithCopy2 () throws IOException {
45
+ try (final MultipartBody multipartBody = buildMultipart ()) {
46
+ final long contentLength = multipartBody .getContentLength ();
47
+ final int bufferSize = (int )contentLength - 1 ;
48
+ final long tranferred = transferWithCopy (multipartBody , bufferSize );
49
+ Assert .assertEquals (tranferred , contentLength );
50
+ }
51
+ }
52
+
43
53
@ Test
44
54
public void transferZeroCopy () throws IOException {
45
55
try (MultipartBody multipartBody = buildMultipart ()) {
@@ -70,8 +80,11 @@ private static File getTestfile() {
70
80
}
71
81
72
82
private static long transferWithCopy (MultipartBody multipartBody ) throws IOException {
83
+ return transferWithCopy (multipartBody , 8192 );
84
+ }
73
85
74
- final ByteBuffer buffer = ByteBuffer .allocate (8192 );
86
+ private static long transferWithCopy (MultipartBody multipartBody , int bufferSize ) throws IOException {
87
+ final ByteBuffer buffer = ByteBuffer .allocate (bufferSize );
75
88
long totalBytes = 0 ;
76
89
while (true ) {
77
90
long readBytes = multipartBody .read (buffer );
You can’t perform that action at this time.
0 commit comments