开发者

How do you read and write http headers in ActionScript?

Is it e开发者_如何学Cven possible to both read and write http headers in actionscript?


Hmm... ok setting them doesn't seem to be a problem.

Pretty straight forward, you just add and array of URLRequestHeader objects to the URLRequest object.

var req:URLRequest = new URLRequest();
var someheader:URLRequestHeader = new URLRequestHeader( "Connection", "OK" );
req.requestHeaders = [someheader];

However, you can't read them in the regular FlashPlayer. This can be done in AIR and Flash Lite on using the requestHeader property on the HTTPStatusEvent.

var loader:URLLoader = new URLLoader();
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onStatus);

private function onStatus( e:HTTPStatusEvent ) : void
{
    var headers:Array = e.requestHeaders; // only available in FlashLite and AIR  
}

This is kinda weird.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜