Android上的Chrome发布Nginx提供的静态MP3文件的双字节范围请求

我正在用Nginx托pipe一个2.9MB的MP3文件。 当我在Android上使用Chrome导航到其URL时,有两个请求:一个正常请求和一个两字节范围请求。

当我将第一个请求作为cURL命令复制并在Mac OS X上执行时,它将整个下载文件。 但是,在Android上,只有3.7KB在双字节范围请求被触发之前下载。 Nginx乖乖地回应只有两个字节的数据,并且Chrome中显示的audio控件不起作用。

我试着设置max_ranges 0 ,禁用etags,gzip等。我似乎无法让Chrome下载文件的其余部分。

第一个要求:

GET /yt/test.mp3 HTTP/1.1 Host: xxx.xxx.xx.xxx Connection: keep-alive Pragma: no-cache Cache-Control: no-cache Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MMB29Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.95 Mobile Safari/537.36 Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8

响应:

HTTP/1.1 200 OK Server: nginx Date: Mon, 15 Feb 2016 01:12:31 GMT Content-Type: audio/mpeg Content-Length: 2891369 Last-Modified: Mon, 15 Feb 2016 00:26:18 GMT Connection: keep-alive ETag: "56c11b2a-2c1e69" X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Accept-Ranges: bytes

第二个请求:

GET /yt/test.mp3 HTTP/1.1 Host: xxx.xxx.xx.xxx Connection: keep-alive Pragma: no-cache Cache-Control: no-cache User-Agent: Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MMB29Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.95 Mobile Safari/537.36 Accept: */* Referer: https://xxx.xxx.xx.xxx/yt/test.mp3 Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8 Range: bytes=0-1

响应:

HTTP/1.1 206 Partial Content Server: nginx Date: Mon, 15 Feb 2016 01:12:32 GMT Content-Type: audio/mpeg Content-Length: 2 Last-Modified: Mon, 15 Feb 2016 00:26:18 GMT Connection: keep-alive ETag: "56c11b2a-2c1e69" X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Content-Range: bytes 0-1/2891369

好吧,相当确定的问题是,Chrome卸载媒体提取和播放到Android MediaPlayer。 在我的情况下,我没有正确设置我的SSL证书(因为我的域名被我的registry暂时错误地列入黑名单)。 我可以手动点击Chrome中的安全警告进入页面,但是我认为只要MediaPlayer试图接pipe资源,它就放弃了证书错误。

不是100%确定这是问题,但我的域名已经恢复服务,现在正在运行。 当我使用原始IP地址时,我可能可以通过禁用HTTPS来挽救自己一些头痛的问题。