1

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 请求无法使用自定义标头发送。你可以看看这里

谢谢!

4

1 回答 1

2

您应该能够毫无问题地向 HTTPService 请求添加标头。我以前做过,在将 Flex 应用程序与 YouTube API 集成时。从概念上讲,它应该是这样的:

var httpService:HTTPService = new HTTPService();
var headerData : Object = new Object();
headerData['Cache-Control'] = 'no-store';
http.headers = headerData;

如果您执行Google 搜索,则会出现其他链接。只要您的服务同时支持 GET 和 POST 请求;我不知道你为什么会遇到任何问题。

于 2013-07-29T18:24:23.613 回答