Skip to content

Conversation

mathieumahe
Copy link

Hi,

I ran into issues when I tried to download big files (mp3 files). The request stopped in the middle of the download, probably because of a OutOfMemoryError. The files had size over 12Mo.

To fix this bug, I created a FileAsyncHttpResponseHandler. This handler writes directly the body of the request in a file specified by the class constructor. Like this, the ram isn't overloaded.

I based my class on the BinaryAsyncHttpResponseHandler's file.

Hope it will help!

@sweetlilmre
Copy link
Contributor

Great idea.

I had similar issues with large files. The handling in the current codebase also results in a double copy of the data in RAM which exacerbates the situation.

See my pull request: #133
I just added some small changes to make memory usage more efficient.
I will look at your patch and attempt to incorporate it.

@ghost
Copy link

ghost commented Jan 8, 2013

Could you consider honouring this request? I want to download files >60Mb and this patch would be of great help!
Thanks.

@edufelipe
Copy link

@loopj Would you consider merging this? Is there anything – such as documentation – needed in order for this pull request to be ready to merge?

@loopj
Copy link
Collaborator

loopj commented Mar 6, 2013

I would prefer not to add an additional class for this functionality (classes are a large component of jar size increase), would it be possible to add this functionality into AsyncHttpResponseHandler

@smarek
Copy link
Member

smarek commented Oct 9, 2013

@edufelipe I really see no issue in merging this request.

@smarek smarek closed this in 9b79fb6 Oct 9, 2013
@ghost ghost assigned smarek Oct 9, 2013
vimalrajpara2006 pushed a commit to vimalrajpara2006/Lib-Droid-Http-Async that referenced this pull request Nov 6, 2013
android-async-http#134

Modified Request params to allow multiple params with the same name
based on android-async-http#136

Fixed unhandled exception AsyncHttpRequest
vimalrajpara2006 pushed a commit to vimalrajpara2006/Lib-Droid-Http-Async that referenced this pull request Nov 6, 2013
# By Peter Edwards (3) and sweetlilmre (1)
# Via Peter Edwards
* sweetlilmre/master:
  Added FileAsyncHttpResponseHandler based on: android-async-http#134
  Big download fixes: Removed unnecessary buffer copy (should allow for larger downloads and helps to combat VM heap constraints) Wrapped allocation in OutOfMemory handler, current behaviour will signal the GC and retry. This _sometimes_ works if GC has a change to run
  Reworked Json handler to parse json on the download thread in the failure case and fixed the messaging to be consistant updated javadocs
  Refactored AsyncHttpResponseHandler.java code base to facilitate a single base class and to use binary as the base response format Refactored dependent AsyncHttpResponseHandler.java classes: BinaryHttpResponseHandler.java, JsonHttpResponseHandler.java Added new ResponseHandler: TextHttpResponseHandler.java Cleaned up exception handling, added missing exception handling and mofified RetryHandler behavior to be more robust Moved handler to separate class to avoid leaks in AsyncHttpRequest.java Added PROGRESS and RETRY messages

Conflicts:
	src/com/loopj/android/http/AsyncHttpRequest.java
	src/com/loopj/android/http/JsonHttpResponseHandler.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants