iTunes Range请求;播客被拒绝 [英] iTunes Range requests; podcast is rejected

查看:103
本文介绍了iTunes Range请求;播客被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个播客添加到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 curling 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}

startend变量是通过解析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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆