Skip to content

Commit 17752cf

Browse files
committed
Merge pull request android-async-http#499 from my519820363/patch-1
Update AsyncHttpResponseHandler.java
2 parents 166963e + ac3b045 commit 17752cf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/src/main/java/com/loopj/android/http/AsyncHttpResponseHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ byte[] getResponseData(HttpEntity entity) throws IOException {
376376
if (contentLength > Integer.MAX_VALUE) {
377377
throw new IllegalArgumentException("HTTP entity too large to be buffered in memory");
378378
}
379-
int buffersize = (contentLength < 0) ? BUFFER_SIZE : (int) contentLength;
379+
int buffersize = (contentLength <= 0) ? BUFFER_SIZE : (int) contentLength;
380380
try {
381381
ByteArrayBuffer buffer = new ByteArrayBuffer(buffersize);
382382
try {
@@ -386,7 +386,7 @@ byte[] getResponseData(HttpEntity entity) throws IOException {
386386
while ((l = instream.read(tmp)) != -1 && !Thread.currentThread().isInterrupted()) {
387387
count += l;
388388
buffer.append(tmp, 0, l);
389-
sendProgressMessage(count, (int) contentLength);
389+
sendProgressMessage(count, (int) (contentLength <= 0 ? 1 : contentLength));
390390
}
391391
} finally {
392392
AsyncHttpClient.silentCloseInputStream(instream);

0 commit comments

Comments
 (0)