URLRequestDefaults.setLoginCredentialsForHost 未设置用户 &授权标头中的密码 [英] URLRequestDefaults.setLoginCredentialsForHost not setting the user & pwd in authorization header

查看:23
本文介绍了URLRequestDefaults.setLoginCredentialsForHost 未设置用户 &授权标头中的密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问受基本身份验证保护的 html 文件.我正在尝试使用 htmlloader 加载此 html 页面并通过 urlRequest 发送请求.我正在使用 URLRequestDefaults 类来设置凭据,但是当我看到在提琴手中发送的请求时,我没有看到由此设置的任何授权标头.我在这里做错了什么.我的代码如下.

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

推荐答案

您应该阅读 API 更仔细:

You should read the API more carefully:

请注意,example.com"、www.example.com"和sales.example.com"均被视为唯一主机.

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

在这种情况下,域不匹配.

In this case, the domains don't match.

这篇关于URLRequestDefaults.setLoginCredentialsForHost 未设置用户 &授权标头中的密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆