URLRequestDefaults.setLoginCredentialsForHost不设置用户安培; PWD在授权头安培、用户、URLRequestDefaults、setLoginCreden

2023-09-08 15:21:38 作者:北海的二号旧灯塔

我要访问的是由基本身份验证保护的HTML文件。 我试图加载这个HTML页中使用的HTMLLoader和发送方URLRequest请求。 我使用URLRequestDefaults类设置的凭据,但是当我看到被发送的小提琴手请求我没有看到任何授权头由这一套。 难道我在这里做得不对。我的code是如下。

  URLRequestDefaults.authenticate = FALSE;
URLRequestDefaults.setLoginCredentialsForHost(www.xyz.com,madhur,夏尔马);
VAR REQ:的URLRequest =新的URLRequest(http://bazinga.xyz.com/MyHtml/index.html);
htmlControl.htmlLoader.load(的URLRequest);
 

解决方案

您应该阅读 API 更仔细:

  

请注意是example.com,www.example.com和sales.example.com分别视为唯一的主机。

在这种情况下,结构域不匹配。

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);

解决方案

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.