1

Is it possible to read the raw content-type of a web server response using the URLLoader class in Actionscript 3? We're receiving self descriping messages over 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

The above example shows the object as type of protobuf, the desc property is a url to an object description, and the messageType is the application name with the corresponding object class.

I would like to be able to read the messageType paramater.

Jack Murphy
  • 2,952
  • 1
  • 30
  • 49

2 Answers2

3

You can retrieve response info by listening for HTTPStatusEvent on 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);
    }
}

Info is stored as Array of Objects, with name and value properties, in event.responseHeaders

  • Would something in the above post result in that coming back as empty? I'm now looking @ https://graph.facebook.com/jack.murphy as a proof of concept, and the m_responseHeaders still come back as an empty array – Jack Murphy Apr 07 '13 at 21:04
  • This only works for AIR applications. Normal Flash applications cannot read the headers. – BlueRaja - Danny Pflughoeft Jan 31 '14 at 20:11
0

@Lee Burrows is correct. However, these seem to only be available for Air Applications. See: unable to get HTTP response code/headers in actionscript 3?

It would be great to be able to find a solution to this for the flash runtime

Community
  • 1
  • 1
Jack Murphy
  • 2,952
  • 1
  • 30
  • 49