无法获得HTTP响应code /头在ActionScript 3? [英] unable to get HTTP response code/headers in actionscript 3?

查看:319
本文介绍了无法获得HTTP响应code /头在ActionScript 3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的URLLoader张贴到服务器。来自服务器的XML响应可以用404或403(禁止)响应错误。但是我无法获得响应codeS。

I'm using URLLoader to POST to a server. The xml response from the server can respond with a 404 or a 403 (forbidden) error. However I am unable to get the response codes.

下面是code

  var urlString:String = "some url";
  var urlRequest:URLRequest = new URLRequest(urlString);
  var loader:URLLoader = new URLLoader();
  loader.addEventListener( Event.COMPLETE, setXMLData );
  loader.addEventListener( IOErrorEvent.IO_ERROR, ioHandler );
  loader.addEventListener( HTTPStatusEvent.HTTP_STATUS, httpStatusHandler );

//...

public function httpStatusHandler(evt:HTTPStatusEvent):void {
    trace("status is " + evt.status);
}

状态始终为0,而​​不管我是否返回200,400,404,301,500,等...

status is always 0 regardless whether i return 200, 400, 404, 301, 500, etc...

任何想法?

推荐答案

有关AIR只有你可以使用HTT presponseStatus。否则,在Flash / Flex的没有空气,你不能。

For AIR Only you can use the httpResponseStatus. Otherwise in Flash/Flex without AIR you cannot.

<一个href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLLoader.html#event:htt$p$psponseStatus" rel="nofollow">http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLLoader.html#event:htt$p$psponseStatus

HTT presponseStatus事件
事件对象类型:flash.events.HTTPStatusEvent HTTPStatusEvent.type属性= flash.events.HTTPStatusEvent.HTTP_RESPONSE_STATUS

httpResponseStatus Event
Event Object Type: flash.events.HTTPStatusEvent HTTPStatusEvent.type property = flash.events.HTTPStatusEvent.HTTP_RESPONSE_STATUS

语言版本:ActionScript 3.0 运行时版本:AIR 1.0 AIR 1.0

Language Version : ActionScript 3.0 Runtime Versions : AIR 1.0 AIR 1.0

如果一个调用load()方法调用尝试通过HTTP访问数据,并且Adobe AIR可以检测并返回状态code的请求调度。 与httpStatus事件时,HTT presponseStatus事件在任何响应数据传送。另外,HTT presponseStatus事件包括responseHeaders和responseURL属性值(它们是未定义对于httpStatus事件。注意,HTT presponseStatus事件(如果有的话)将前(和除了要发送)的任何完整或错误事件。

Dispatched if a call to the load() method attempts to access data over HTTP, and Adobe AIR is able to detect and return the status code for the request. Unlike the httpStatus event, the httpResponseStatus event is delivered before any response data. Also, the httpResponseStatus event includes values for the responseHeaders and responseURL properties (which are undefined for an httpStatus event. Note that the httpResponseStatus event (if any) will be sent before (and in addition to) any complete or error event.

这篇关于无法获得HTTP响应code /头在ActionScript 3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆