iTunes Range请求;播客被拒绝 [英] iTunes Range requests; podcast is rejected
问题描述
我正在尝试将一个播客添加到iTunes中,该播客正在处理字节范围请求.我可以通过curl
音频文件来确认:
There is a podcast that I'm trying to add to itunes which is handling byte-range requests. I can confirm this by curl
ing the audio file:
curl -H "Range: bytes=50-100" --head http://media.site.org/podcasts/upload/2012/08/15/audio-081512.mp3
HTTP/1.1 200 OK
Server: nginx/1.2.0
Date: Wed, 15 Aug 2012 22:28:40 GMT
Content-Type: audio/mpeg
Content-Length: 51
Connection: keep-alive
X-Powered-By: Express
Status: 206 Partial Content
Accept-Ranges: bytes
Content-Range: bytes 50-100/1441605
Access-Control-Allow-Origin: *
但是,当我尝试在iTunes中输入供稿页面的URL时,出现以下错误:
However, when I try to enter the URL to the feed page into iTunes, I get the following error:
您的供稿有问题.您的剧集托管在不支持字节范围请求的服务器上.启用字节范围请求,然后再次尝试提交."
"There is a problem with your feed. Your episodes are hosted on a server which doesn't support byte-range requests. Enable byte-range requests and try your submission again."
音频文件与供稿文件托管在不同的服务器上,并由节点服务器提供服务...但是我不明白为什么只要响应头正确,那为什么不重要.
The audio files are hosted on a different server than the feed file, and are being served by a Node server... but I don't see why that should matter as long as the response headers are correct.
我从同一台服务器提供了其他一些播客,这些播客是之前添加的. iTunes开始要求字节范围支持,但它们仍然可以正常工作(在包括iPhone在内的任何平台上,都表明字节范围请求确实有效).
I have some other podcasts being served from the same server, which were added before iTunes started requiring byte-range support, and they still work fine (on any platform, including iPhone, indicating that the byte-range requests are indeed working).
推荐答案
如果响应头的HTTP状态为200
,则iTunes将拒绝播客,即使服务器正在接受字节范围的请求也是如此.我要做的就是强行使用206 Partial Response
标头.在Node中,它看起来像这样(CoffeeScript):
If the response headers have an HTTP Status of 200
, then iTunes will reject the podcast even if the server is accepting byte-range requests. All I had to do was force a 206 Partial Response
header. In Node, it looks like this (CoffeeScript):
res.writeHead 206, headers
headers
是一个散列,包含用于字节范围请求的所有适当的标头,例如:
headers
being a hash containing all the proper headers for byte-range requests, such as:
headers:
"Accept-Ranges": "bytes"
"Content-Range": "bytes #{start}-#{end}/#{length}
start
和end
变量是通过解析Range
请求标头获得的,而length
是音频文件的实际大小.我还把"Cache-Control": "no-cache"
丢进去了.
The start
and end
variables are acquired by parsing the Range
request header, and the length
is the actual size of the audio file. I also threw in "Cache-Control": "no-cache"
for good measure.
这篇关于iTunes Range请求;播客被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!