Flex 应用程序的后续请求不会发送授权标头
我正在尝试访问受基本身份验证保护的 html 文件。下面是执行此操作的代码,但我仍然收到身份验证对话框。我检查了 fiddler,发现第一个请求存在授权标头,但对于后续请求,则要求加载 .js、css 和 .js、css 等。图像未添加授权标头。这就是我收到身份验证对话框的原因。 有没有办法将授权标头添加到后续请求中?
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);
多谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
上述解决方案对我不起作用。以下是替代解决方案。
请参阅相关问题 URLRequestDefaults.setLoginCredentialsForHost 未设置用户 &授权标头中的密码
The above solution didn't worked for me. Below is the alternate solution.
See related question URLRequestDefaults.setLoginCredentialsForHost not setting the user & pwd in authorization header