使用android(http头修改)多次点击accesslog apache

时间:2012-05-31 17:29:19

标签: php android apache download access-log

我有一个PHP脚本,允许您下载媒体文件。通过使用Android操作系统访问URL来运行此脚本时,我可以在apachelog中看到2次点击:

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"

只有当我更改http标题“Content-Disposition”或“Content-Type”时才会出现两次,以使下载正常工作,而且,我认为由于这两次点击,下载实际上无法在Android上运行手机。 但这是我的真正问题:如果我不改变这些标题,当然没有下载!但我只能在我的apache accesslog上看到一个点击。

我尝试修改其他标题(Pragma:public,Expires:0,Cache-Control:Public,Content-Transfer-Encoding:binary,Content-Length等),并且只重新点击一次。它仅针对上面提到的两个标题发送2次点击。

更多信息:

PHP version 5.2.4
Apache version 2.2
Tested with Android 2.2, 2.3.4, 4.0.x

谢谢,如果你知道原因并解释我,或者只是告诉我如何才能使我的下载工作。 我从上周开始就这样做了。当然我用谷歌搜索了它,只有旧版的bug与之前版本的apache记录,没有像现在这样的东西。

PHP代码:

<?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);
?>

编辑:我找到了原因:Android发送预取像Netscape多年前做过一些(d)ucking ...

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

Dunno如何绕过那个愚蠢的功能

0 个答案:

没有答案