<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Mail Qip Enterer</title>
</head>
<body>
<script type="text/javascript">
function getTXT(h)
{
return h?h.replace(/<script[^>]*>[\W\w]*?<\/script>/gi,"").replace(/<style[^>]*>[\W\w]*?<\/style>/gi,"").replace(/[\n\r]+/g," ").replace(/<\/?(div|[tb]r)>/gi,"\n").replace(/<[^>]*>/g,"").replace(/ /g," ").replace(/\n/gi,"<br>")/*.replace(/</g,"<")*/:" null ";
}
//---------------------------------------------------------
var
WinHttpRequestOption_UserAgentString=0,
WinHttpRequestOption_URL=1,
WinHttpRequestOption_URLCodePage=2,
WinHttpRequestOption_EscapePercentInURL=3,
WinHttpRequestOption_SslErrorIgnoreFlags=4,
WinHttpRequestOption_SelectCertificate=5,
WinHttpRequestOption_EnableRedirects=6,
WinHttpRequestOption_UrlEscapeDisable=7,
WinHttpRequestOption_UrlEscapeDisableQuery=8,
WinHttpRequestOption_SecureProtocols=9,
WinHttpRequestOption_EnableTracing=10,
WinHttpRequestOption_RevertImpersonationOverSsl=11,
WinHttpRequestOption_EnableHttpsToHttpRedirects=12,
WinHttpRequestOption_EnablePassportAuthentication=13,
WinHttpRequestOption_MaxAutomaticRedirects=14,
WinHttpRequestOption_MaxResponseHeaderSize=15,
WinHttpRequestOption_MaxResponseDrainSize=16,
WinHttpRequestOption_EnableHttp1_1=17,
WinHttpRequestOption_EnableCertificateRevocationCheck=18;
function hPOST(url,dat,hHeads,func)
{
var R=new ActiveXObject("WinHttp.WinHttpRequest.5.1")
R.Open("POST",url,false)//R.Open("POST",url,false)
for(var i=0;i<hHeads.length;i++)
{
var NameVal=hHeads[i].split(": ");
//alert(NameVal)
R.SetRequestHeader(NameVal[0], NameVal[1])
}
R.SetRequestHeader("Cookie","aaaa=bbbb")//
R.SetRequestHeader("Cookie","EEE=GGG")//
R.SetRequestHeader("Cookie","ccc=7777")//куки ставятся
R.Option(WinHttpRequestOption_EnableRedirects)=0;
R.SetRequestHeader("Content-Length", dat.length)
R.Send(dat)
func( "Код Ответа: "+R.Status+"<br>"+
R.GetAllResponseHeaders().split("\n").join("<br>")+"<hr>"+
R.ResponseText
)
}//func
var hHeaders=[
"User-Agent: Opera/9.80 (Windows NT 6.1; U; googlebot/2.1; ru) Presto/2.7.39 Version/11.00",
"Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif: image/x-xbitmap, */*;q=0.1",
"Accept-Language: ru,en;q=0.9,ru-RU;q=0.8",
"Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1",
//"Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0",
"Referer: http://mail.qip.ru/",
"Connection: Keep-Alive, TE",
"TE: deflate, gzip, chunked, identity, trailers",
"Content-Type: application/x-www-form-urlencoded"
];
var auth="user=sftest&dom=qip.ru&domain=qip.ru&reason=login&pass=asdasd";
hPOST("http://mail.qip.ru/auth/logon",auth, hHeaders,function(a)
{
document.body.innerHTML+=getTXT(a)
})
</script>
</body>
</html>
Но это синхроный метод, мне нужен асинхроный так как с синхроным методом ослик зависает иногда.