2

我正在尝试使用 html5 音频播放 *.wav。客户端js看起来像

<script>    
    document.getElementById("player").src = "/moh/play/?track_id=1";
    document.getElementById("player").play();
</script>

服务器端 php+Zend 1.8 看起来像

public function responceWav(MyNameSpace_Model_Track $model_track)
    {
        $this->getResponse()->setHeader("Content-Length", @filesize($model_track->getWAVPath()))
            ->setHeader("Connection", "Keep-Alive")
            ->setHeader("Content-Disposition", "attachment; filename=\"" . $model_track->getFileName() . "\".wav")
            ->setHeader("ETag", md5($model_track->getWAVPath() . time()))
            ->setHeader("Content-Type", "audio/x-wav");

        @readfile($model_track->getWAVPath());

        $this->view->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

    }

在 FF 中它工作得很好,但在 Safari 6.0.1 中,当我尝试跟踪时,会话(通过 cookie)被终止。通过wireshark转储:

1 个来自 Safari 的请求

GET /moh/play/?track_id=1 HTTP/1.1
Host: domain.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14
Accept: */*
Range: bytes=0-1
Accept-Encoding: identity
Referer: http://domain.com/
X-Playback-Session-Id: E8F45DB5-D018-4088-8BD3-9077ECE23F31
Cookie: PHPSESSID=d0hl91519jfm2jopklbdcsre14
Connection: keep-alive

HTTP/1.1 200 OK
Date: Thu, 11 Oct 2012 08:31:14 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=aksnmpn4vquid961jp5rbthrk6; expires=Thu, 11-Oct-2012 09:01:14 GMT; path=/
Content-Length: 4118616
Connection: Keep-Alive, close
Content-Disposition: attachment; filename="cbde895a22ad1824b700f7118263bc08".wav
Etag: e1e7c9fad8c9a607ecdd5c045d5fd0bd
Content-Type: audio/x-wav

AppleCoreMedia 的第二次请求

GET /moh/play/?track_id=1 HTTP/1.1
Host: domain.com
User-Agent: AppleCoreMedia/1.0.0.12C54 (Macintosh; U; Intel Mac OS X 10_8_2; ru_ru)
Accept: */*
Range: bytes=0-1
Accept-Encoding: identity
Cookie: PHPSESSID=aksnmpn4vquid961jp5rbthrk6
Connection: keep-alive

HTTP/1.1 200 OK
Date: Thu, 11 Oct 2012 08:31:14 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=ec0fi4r90349h5icbaq4h4km64; expires=Thu, 11-Oct-2012 09:01:14 GMT; path=/
Content-Length: 4118616
Connection: Keep-Alive, close
Content-Disposition: attachment; filename="cbde895a22ad1824b700f7118263bc08".wav
Etag: e1e7c9fad8c9a607ecdd5c045d5fd0bd
Content-Type: audio/x-wav

QuickTime 插件的第三次请求

GET /moh/play/?track_id=1 HTTP/1.1
Host: domain.com
User-Agent: QuickTime/7.7.1 (qtver=7.7.1;cpu=IA32;os=Mac 10.8.2)
Accept: */*
Cookie:  PHPSESSID=ec0fi4r90349h5icbaq4h4km64;
Connection: close

HTTP/1.1 200 OK
Date: Thu, 11 Oct 2012 08:31:14 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=c7iu5ehbp852q0oi2m7evgjea3; expires=Thu, 11-Oct-2012 09:01:15 GMT; path=/
Content-Length: 4118616
Connection: Keep-Alive, close
Content-Disposition: attachment; filename="cbde895a22ad1824b700f7118263bc08".wav
Etag: a16b449dade53093415ac609dc5be199
Content-Type: audio/x-wav

Safari 的第 4 次请求(您好登录屏幕

POST /user/index HTTP/1.1
Host: domain.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14
Content-Length: 0
Accept: application/json, text/javascript, */*; q=0.01
Origin: http://domain.com
X-Requested-With: XMLHttpRequest
Referer: http://domain.com/
Accept-Language: ru
Accept-Encoding: gzip, deflate
Cookie: PHPSESSID=ec0fi4r90349h5icbaq4h4km64
Connection: keep-alive

HTTP/1.1 200 OK
Date: Thu, 11 Oct 2012 08:31:42 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 2040
Connection: close
Content-Type: text/html; charset=UTF-8

我不明白可能是什么问题。

4

0 回答 0