2013-04-07 76 views
0

是否可以使用Actionscript 3中的URLLoader類讀取Web服務器響應的原始內容類型?我們通過http接收自descriping消息:Actionscript 3讀取響應內容類型

HTTP/1.1 200 OK 
Cache-Control: max-age=0, private, must-revalidate 
Content-Type: application/x-protobuf; desc="http://domain.herokuapp.com/pb_message.desc"; messageType="SomeApp.YourCustomClass"; delimited=true; charset=utf-8 
Date: Sat, 06 Apr 2013 23:16:07 GMT 
Etag: "d27199cd1500953f6f4512c76bc58f28" 
Server: WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09) 
X-Rack-Cache: miss 
X-Request-Id: 57e83c24a04a03959eeed4ca0d3ab961 
X-Runtime: 0.044153 
Content-Length: 13 
Connection: keep-alive 

上面的例子示出了對象類型的protobuf的,所述內容描述屬性是一個URL的一個對象的描述,並且爲messageType是應用程序名與對應的對象類。

我希望能夠閱讀messageType參數。

回答

2

您可以通過偵聽HTTPStatusEvent上的URLLoader檢索響應信息:

myLoader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, httpHandler); 

function httpHandler(event:HTTPStatusEvent):void 
{ 
    for each (var object:Object in event.responseHeaders) 
    { 
    trace(object.name+" : "+object.value); 
    } 
} 

信息存儲爲對象的數組,名稱和值的屬性,在event.responseHeaders

+0

將東西在上面的帖子結果在回來爲空?我現在正在查看@ https://graph.facebook.com/jack.murphy作爲概念驗證,並且m_responseHeaders仍然作爲空數組返回 – 2013-04-07 21:04:30

+0

這僅適用於AIR應用程序。正常的Flash應用程序無法讀取標題。 – 2014-01-31 20:11:52

相關問題