URLRequestDefaults.setLoginCredentialsForHost not setting the user & pwd in authorization header

二次信任 提交于 2019-12-12 01:34:24

问题


I want to access html files which are protected by basic authentication. I am trying to load this html page using htmlloader and sending the request by urlRequest. I am using URLRequestDefaults class to set the credentials but when I see the request being send in the fiddler I don't see any authorization header being set by this. Am I doing something wrong here. My code is below.

URLRequestDefaults.authenticate = false;
URLRequestDefaults.setLoginCredentialsForHost("www.xyz.com", "madhur", "sharma");
var req:URLRequest = new URLRequest("http://bazinga.xyz.com/MyHtml/index.html");
htmlControl.htmlLoader.load(urlRequest);

回答1:


You should read the API more carefully:

Note that "example.com", "www.example.com", and "sales.example.com" are each considered unique hosts.

In this case, the domains don't match.



来源:https://stackoverflow.com/questions/6359670/urlrequestdefaults-setlogincredentialsforhost-not-setting-the-user-pwd-in-auth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!