flash URLRequest 权限认证

HTTP权限认证的基本概念

https://en.wikipedia.org/wiki/Basic_access_authentication


添加认证头信息

var encoder:Base64Encoder = new Base64Encoder();
encoder.encode(username + ':' + password);
var req:URLRequest = new URLRequest();
req.requestHeaders.push(new URLRequestHeader("Authorization", "Basic " + encoder.toString()));


flash中使用URLRequest仅支持在POST下提交自定义header,flash令人很烦的地方,下面链接中使用了变通的方法即socket,但这样在开发环境下就很难捕捉到http消息(Fiddler中无法抓到http请求消息)

http://stackoverflow.com/questions/490806/http-basic-authentication-with-httpservice-objects-in-adobe-flex-air


去除http认证时,网页弹出认证输入框(未经验证)

http://stackoverflow.com/questions/404199/how-can-i-avoid-an-authentication-dialog-in-flex-when-using-httpservice-or-urlre


综上,flash底层的网络接口的确是有诸多限制(安全沙箱冲突,只支持POST,GET, GET时无法自定义header)

你可能感兴趣的:(http,socket,base64,Flash)