2

*.wav を html5 オーディオで再生しようとしています。クライアント側の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 によるダンプ:

safariによる1件のリクエスト

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 による 2 番目の要求

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 プラグインによる 3 番目のリクエスト

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