Note that there are some explanatory texts on larger screens.

plurals
  1. POmultiple hit on accesslog apache with android (http headers modified)
    primarykey
    data
    text
    <p>I have a PHP script which allows you to download media files. When I run this script by accessing via URL with an Android OS, I can see 2 hits in the apachelog:</p> <pre class="lang-none prettyprint-override"><code>192.168.xxx.xx - - [31/May/2012:15:30:57 +0100] "GET /myScript.php?myParams=myValues HTTP/1.1" 200 409632 "http://myReferer" "Mozilla/5.0 (Linux; U; Android 2.1-update1; fr-fr; HTC Desire 1.19.161.5 Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17" 192.168.xxx.xx - - [31/May/2012:15:30:57 +0100] "GET /myScript.php?myParams=myValues HTTP/1.1" 200 409632 "http://myReferer" "Mozilla/5.0 (Linux; U; Android 2.1-update1; fr-fr; HTC Desire 1.19.161.5 Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17" </code></pre> <p>It appears twice only if I change the http headers "Content-Disposition" or "Content-Type", to make the download works, and, I think because of the two hits, the download actually doesn't work on Android phones. But that's my true problem: if I don't change these headers, there's no dowload of course! But I can see only one hit on my apache accesslog.</p> <p>I try to modify others headers (Pragma: public, Expires: 0, Cache-Control: Public, Content-Transfer-Encoding: binary, Content-Length, etc) and only one hit again. It send 2 hits only for both headers mentionned above.</p> <p>More info:</p> <pre class="lang-none prettyprint-override"><code>PHP version 5.2.4 Apache version 2.2 Tested with Android 2.2, 2.3.4, 4.0.x </code></pre> <p>Thanks if you know why and explain me, or just telling me how can I make my download work. I'm on this since last week. Of course I googled it and only old bugs with apache log from previous version, there's nothing like I have now.</p> <p>PHP code:</p> <pre class="lang-php prettyprint-override"><code>&lt;?php //$path is the absolute path of the file I want to download (dl) header("Pragma: public"); header("Expires: 0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: " . getFileMIME($path)); //return "audio/mpeg" since I want to dl *.mp3 header('Content-Disposition: attachment; filename="' . $filename . '";'); //basename of my file header("Content-Transfer-Encoding: binary"); header('Content-Length: ' . filesize($path)); readfile($path); ?&gt; </code></pre> <p>EDIT : I find why: Android send a pre-fetch like Netscape did some (d)ucking years ago...</p> <pre class="lang-none prettyprint-override"><code>While pre-fetching of content is a great feature for most consumers, it does have its share of disadvantages. If you have a tight data cap, the last thing you want is your browser to waste your bandwidth by loading pages you might not even want to visit. It will also create headaches for webmasters by registering fake hits that will increase bandwidth and server resource consumption, besides messing up analytics. Netscape had earlier experimented with pre-fetching, but it allowed the webmasters to be in control. Source : http://techie-buzz.com/browsers/chrome-17-changes-review.html </code></pre> <p>Dunno how to bypass that stupid functionnality</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload