Question

That is really happening. I made test in PHP to confirm this.

I created a test.php file and put:

<?php
    error_log('Downloading...');
    header('Content-type: application/force-download');
    header('Content-Disposition: attachment; filename="test.txt"');
    echo 'test android download';
?>

So, when I open www.myurl/test.php via any Android mobile browser, in the error_log.log I get "Downloading..." two times.

When i open same URL in any other Mobile OS(Windows, IOS, etc.) I get only one time "Downloading..." in error_log.log file.

Does anyone know what's going on and how to avoid this ??

This is a big problem for me, because I perform user charging when somebody download a file. And now from Android Phones there are 2 charges for 1 downloaded file.

Was it helpful?

Solution

I am in a dead end :(

http://code.google.com/p/android/issues/detail?id=1978

The browser needs to hit the server to determine that something is a download, and than the download manager has to separately contact the server for downloading.

So, Android fire up first request to open dialogue box for "are you sure? - yes/no". And if user click "Yes" Android Forward request to Android DownloadManager and manager send second request to download file. (some Android version send request to DownloadManager immediately)

The problem is that both request, first and second, are type of GET (not HEAD).

OTHER TIPS

In my case I receive two requests. First one throws org.apache.catalina.connector.ClientAbortException with description java.net.SocketException: Connection reset by peer: socket

So I just catch that exception and write log. I guess you can do the same and charge customers only after successful downloading

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top