Internet Explorer (6,7)
Flex( HTTPService
) 加载XML
时存在已知问题SSL
。Flash PlayerError #2032: Stream Error
在这种情况下抛出。
正如微软和其他人所建议的那样,应该在服务器端设置“Cache-Control: no-store”来解决这个问题。
不幸的是,我无法访问应用程序的后端,因此我应该通过 Flex 解决它。
我的目标是在运行时加载带有配置的 xml 文件。
Flex 中不允许请求的自定义标头GET
(如果我错了,请告诉我)。因此我决定通过POST
请求来完成我的目标,令人惊讶的是它运行得非常好。
这是我附带的代码:
var httpService:HTTPService = new HTTPService();
httpService.url = 'config.xml';
httpService.method = 'POST';
httpService.requestTimeout = 10;
httpService.contentType = "application/xml";
httpService.headers["Cache-Control"] = "no-store";
httpService.resultFormat = "e4x";
var localResponder:Responder = new Responder(
function(event:ResultEvent):void {
//event.result returns the required xml configuration
},
function(event:FaultEvent):void {
});
var token:AsyncToken = httpService.send({});
token.addResponder(localResponder);
我的问题是:POST
发送请求而不是GET
请求时会不会有任何副作用?
更新:
为了证明 GET-requests 被剥离了标头,我采用了@Reboog711 提供的代码并创建了一个小应用程序。这是代码:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.rpc.http.HTTPService;
protected function sendHTTPRequest(event:MouseEvent):void
{
var httpService:HTTPService = new HTTPService();
httpService.url = 'xml.xml';
var headerData : Object = new Object();
headerData['Cache-Control'] = 'no-store';
httpService.headers = headerData;
httpService.send();
}
]]>
</fx:Script>
<s:Button label="SEND HTTP REQUEST"
horizontalCenter="0" verticalCenter="0" click="sendHTTPRequest(event)"/>
</s:Application>
这是我在发送 HTTP 请求时在 Charles 应用程序中看到的内容。
你可以在这里自己测试。此外,当我试图解决我的问题时,我已经看到许多证据表明 GET 请求无法使用自定义标头发送。你可以看看这里。
谢谢!