I have an air app and I want to add proxy-authorization header whenever my client is behind a proxy. I am adding 'proxy-Authoriztion' header in urlRequest headers but still I am getting the OS prompt for username/password.
var loader:HTMLLoader = new HTMLLoader();
var be:Base64Encoder = new Base64Encoder();
be.insertNewLines = false;
be.encode("test" + ":" + "test");
var urlRequest:URLRequest = new URLRequest("http://google.co.in");
urlRequest.authenticate = false;
urlRequest.requestHeaders.push(new URLRequestHeader("Proxy-Authorization","Basic "+ be.toString()));
page.htmlLoader.load(urlRequest);
I checked fiddler and what I see is that 1st Response is 301 and proxy-authorization header is added 2nd Response is 407 and开发者_如何转开发 proxy-authorization header is not added.
After this I get the OS prompt. Anybody has any ideas on this?
I had that exact same problem, just for Authorization headers. Here is my solution:
var service:HTTPService = new HTTPService();
...
var encoder:Base64Encoder = new Base64Encoder();
encoder.encode(userName+':'+password);
service.headers["Authorization"] = "Basic " + encoder.toString();
...
service.send();
For some none apparent reason this works. Try that ( but remember to change the "Authorization" header in my example with "Proxy-Authorization")
精彩评论