unable to get HTTP response code/headers in actionscript 3?

后端 未结 3 1438
花落未央
花落未央 2021-01-18 22:45

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

相关标签:
3条回答
  • 2021-01-18 23:01

    As a late answer (FWIW):

    From what I've read, the status codes you get depend on what browser the Flash player is running in.

    One article says you can only get 200 or 500. One SO question says they were getting 207 in Chrome but 0 in Firefox.

    I, personally, have tested using the dev Flash player as well as an ActiveX version and was able to get many different 2XX/4XX HTTP status codes (but couldn't get the 3XX redirect codes I tried because the requests got redirected and returned 200s).

    0 讨论(0)
  • 2021-01-18 23:17

    the ability to look at the headers is limited in several browsers, therefore flash has a problem with being passed the information. this is mainly blamed on the browser settings, but i have yet to find one where it actually works. status event output.

    i gave up and had the file print the response code in my projects, not wonderful (and somewhat defeating the point) but seems to work.

    0 讨论(0)
  • 2021-01-18 23:24

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

    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLLoader.html#event:httpResponseStatus

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

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

    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.

    0 讨论(0)
提交回复
热议问题