ServerXMLHTTP not sending proxy credentials with 301 re-direct

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
JScript / Msxml2.ServerXMLHTTP.6.0
Hello,
My issue is using serverXMLHTTP with a proxy server. If I send the Url request yahoo.com and the proper proxy credentials, the proxy correctly returns the 301 re-direct and "www.yahoo.com". The http object then sends back a request for www.yahoo.com but
it does NOT send the proxy credentials with the 2nd request so the proxy returns 407-missing credentials. I have seen this by using Wireshark to get a packet capture of the conversation between the client and the proxy. How can I force the http object to always
send the credentials when a re-direct happens?
Code:
 //cscript pxurl.js /u:<url-no-http><br/>
// test url via proxy server - credentials required for proxy<br/>
var colNamedArgs;    <br/>
colNamedArgs = WScript.Arguments.Named;<br/>
if(colNamedArgs.Exists("u")) {<br/>
    var thisUrl = colNamedArgs.Item("u");<br/>
}<br/>
var httpUrl = "http://" + thisUrl;<br/>
var objHttp = new ActiveXObject("Msxml2.ServerXMLHTTP.6.0");<br/>
objHttp.setOption(2, 13056);// Ignore all SSL Cert issues<br/>
objHttp.open("GET", httpUrl, false); // GET Method, asynchronous=false<br/>
objHttp.setProxyCredentials("user1", "pass1");<br/>
objHttp.setProxy(2, "bcproxy");<br/>
objHttp.setRequestHeader("User-Agent", "Mozilla/5.0+(compatible;+MSIE+7.0;+Windows+NT+5.1) Gecko/20110803 Firefox/3.6.19");<br/>
objHttp.send();    <br/>
if (objHttp.status == "200") {        //Return not OK<br/>
    WScript.Echo("OK!!!");<br/>
}<br/>
else {<br/>
    WScript.Echo("Status HTTP Code [" + objHttp.status  + "] Status Text [" +<br/>
         objHttp.statusText + "] Response Text [" + objHttp.responseText + "]");<br/>
}
<br/>

View the full article
 
Back
Top