在ActionScript3中使用URLLoader类可以读取web服务器响应的原始内容类型吗?我们正在通过http接收自我描述消息:
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类型,desc属性是对象描述的url,messageType是具有相应对象类的应用程序名称。
我希望能够读取messageType参数。
发布于 2013-04-07 09:30:43
您可以通过在URLLoader上侦听HTTPStatusEvent来检索响应信息:
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);
}
}Info以对象数组的形式存储在event.responseHeaders中,具有name和value属性
发布于 2013-04-08 05:16:05
@Lee Burrows是正确的。然而,这些似乎只适用于Air应用程序。请参阅:unable to get HTTP response code/headers in actionscript 3?
如果能为flash运行时找到解决方案,那就太好了。
https://stackoverflow.com/questions/15857638
复制相似问题