I am trying to access html files protected by basic authentication. Below is the code to do that but I still get the authentication dialog. I checked the fiddler and found that for the first request authorization header is present but for the subsequent requests which is requested to load the .js, css & images the authorization header is not added. This is the reason I am getting the auth dialog. Is there a way to add authorization header to the subsequent requests as well?
var loader:HTMLLoader = new HTMLLoader();
var be:Base64Encoder = new Base64Encoder();
be.insertNewLines = false;
be.encode("madhur" + ":" + "sharma");
var urlRequest:URLRequest = new URLRequest("http://bazinga/myHtmlFiles/index.html");
urlRequest.requestHeaders.push(new URLRequestHeader("Authorization开发者_高级运维","Basic "+ be.toString()));
page.htmlLoader.load(urlRequest);
Thanks a lot
The above solution didn't worked for me. Below is the alternate solution.
URLRequestDefaults.authenticate = false;
URLRequestDefaults.setLoginCredentialsForHost("bazinga.xyz.com", "madhur", "sharma");
var req:URLRequest = new URLRequest("http://bazinga.xyz.com/MyHtml/index.html");
htmlControl.htmlLoader.load(urlRequest);
See related question URLRequestDefaults.setLoginCredentialsForHost not setting the user & pwd in authorization header
精彩评论