I have a Flash object hosted on foo.com. When I run it, I want it to send a HTTP request to foo.com, and retrieve the results along with HTTP headers.
How would one achieve this with Flash? (AS 3)
I have a Flash object hosted on foo.com. When I run it, I want it to send a HTTP request to foo.com, and retrieve the results along with HTTP headers.
How would one achieve this with Flash? (AS 3)
You would use URLLoader
to send a URLRequest
to foo.com. You can add headers by pushing new URLRequestHeader's
onto the URLRequest.requestHeaders
array. I'm not sure about reading the headers though. I think it's possible with sockets and AIR seems to have the httpResponseStatus
event (not httpStatus
like the Flash API) which
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.