如何解决错误:[strict] 由于错误的内容类型“binary/octet-stream”而忽略 http://my.domain.com/crossdomain.xml 上的策略文件?
这是一个 ActionScript 3 问题...
我在 my.domainA 上托管一个 swf,并且我正在使用以下代码从 my.domainB 请求一个 jpg(当然我正在混淆域名):
var request:URLRequest = new URLRequest(result.image);
request.requestHeaders.push(header);
var context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain, SecurityDomain.currentDomain);
content = new Loader();
content.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
content.load(request, context);
Domain B has a cross domain xml 文件如下所示:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>"
但是,我收到此错误:
“错误:[严格] 忽略策略文件 my.domainB.com/crossdomain.xml 由于内容类型错误 “二进制/八位字节流”。请参阅 www.adobe.com/go/strict_policy_files 解决这个问题。”
有谁知道如何解决这个问题吗?这对于 crosdomain.xml 文件或我请求的 jpg 来说内容类型是否错误?
任何帮助表示赞赏。
This is an ActionScript 3 problem...
I am hosting a swf on my.domainA and I am requesting a jpg from my.domainB ( of course I'm obsfucating the domain names ) the using this code:
var request:URLRequest = new URLRequest(result.image);
request.requestHeaders.push(header);
var context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain, SecurityDomain.currentDomain);
content = new Loader();
content.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
content.load(request, context);
Domain B has a cross domain xml file which looks like this:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>"
However, I get this error:
"Error: [strict] Ignoring policy file at
my.domainB.com/crossdomain.xml due to bad Content-Type
'binary/octet-stream'. See www.adobe.com/go/strict_policy_files to
fix this problem."
Does anyone have any idea how I can resolve this? Is this bad Content-type for the crosdomain.xml file or the jpg I am requesting?
Any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
第一个猜测是您的跨域文件被拒绝,而不是 jpg。
在您的代码中,我们看不到标头变量的内容...问题可能来自您的请求的处理方式吗?
您尝试过更简单的方法吗?
像这样的东西:
var request:URLRequest = new URLRequest(result.image);
var 内容:Loader = new Loader();
content.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded); content.load(请求, new LoaderContext(true));
A first guess would be that your crossdomain file is being rejected, rather than the jpg.
In your code we can't see the content of your header variable... could the problem come from the way your request is handled?
Have you tried a simpler approach?
Something like:
var request:URLRequest = new URLRequest(result.image);
var content:Loader = new Loader();
content.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded); content.load(request, new LoaderContext(true));
我从来没有遇到过这个问题,但该消息似乎表明问题是跨域文件提供了错误的内容类型(二进制/八位字节流而不是文本/xml)。你能检查一下吗?一种简单的方法是使用 firebug(或其他工具)查看响应标头来加载 xml。
顺便说一句,您正在加载图像。也许您已经意识到这一点,但以防万一:如果您不需要操作图像像素数据,则可以在不跨域的情况下加载它。只是不要尝试从中创建 BitmapData 图像,也不要访问 loader.content。通过加载器对象将图像放置在显示列表上(或将其删除),加载器对象是一个显示对象,可以充当真实图像的“代理”。
I've never had this problem, but the message seems to indicate that the problem is that the crossdomain file is served with the wrong content-type (binary/octet-stream instead of text/xml). Can you check that? A simple way would be loading the xml with looking at the response headers with firebug (or some other tool).
By the way, you are loading an image. Probably you are aware of this, but just in case: if you don't need to manipulate the image pixel data, you can just load it without a crossdomain. Just don't try to create a BitmapData image from it and don't access loader.content either. Place the image on the display list (or remove it) through the loader object, that is a display object and can act like a "proxy" for the real image.