Skip to content

Commit 2e0e864

Browse files
committed
1 parent cef711f commit 2e0e864

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public AsyncHttpResponseHandler() {
179179
* @param totalSize total size of file
180180
*/
181181
public void onProgress(int bytesWritten, int totalSize) {
182-
Log.d(LOG_TAG, String.format("Progress %d from %d (%d)", bytesWritten, totalSize, bytesWritten / (totalSize / 100)));
182+
Log.d(LOG_TAG, String.format("Progress %d from %d (%d)", bytesWritten, totalSize, totalSize > 0 ? bytesWritten / (totalSize / 100) : -1));
183183
}
184184

185185
/**
@@ -370,11 +370,9 @@ byte[] getResponseData(HttpEntity entity) throws IOException {
370370
if (contentLength > Integer.MAX_VALUE) {
371371
throw new IllegalArgumentException("HTTP entity too large to be buffered in memory");
372372
}
373-
if (contentLength < 0) {
374-
contentLength = BUFFER_SIZE;
375-
}
373+
int buffersize = (contentLength < 0) ? BUFFER_SIZE : (int) contentLength;
376374
try {
377-
ByteArrayBuffer buffer = new ByteArrayBuffer((int) contentLength);
375+
ByteArrayBuffer buffer = new ByteArrayBuffer((int) buffersize);
378376
try {
379377
byte[] tmp = new byte[BUFFER_SIZE];
380378
int l, count = 0;

0 commit comments

Comments
 (0)