Jump to content

Recommended Posts

Wouldn't your request miss post data that way?

 

Maybe to do it like this:

;...
$sPostData = "targetUrl=%2Fcqweb%2Fmain%3Fcommand%3DGenerateMainFrame&ratl_userdb=A01%2CC01%2CD01%2CD02%2CF01%2CF02%2CG01%2CG02%2CGA01%2CGA02%2CH01%2CH02%2CI01%2CK01%2CK02%2CM01%2CN01%2CO01%2CU01%2CWEBUI%2CX01%2CZ02%2CZ03%2CZ04%2C&test=&clientServerAddress=https%3A%2F%2Fcqweb.server.address.com%2Fcqweb%2Flogin&username=user&password=password%21&schema=TN_MP3&userDb=D01"

_WinHttpSendRequest($h_openRequest, Default, Default, StringLen($sPostData))

_WinHttpWriteData($h_openRequest, $sPostData)
;...
 

Or even better:

;...
$sPostData = "targetUrl=%2Fcqweb%2Fmain%3Fcommand%3DGenerateMainFrame&ratl_userdb=A01%2CC01%2CD01%2CD02%2CF01%2CF02%2CG01%2CG02%2CGA01%2CGA02%2CH01%2CH02%2CI01%2CK01%2CK02%2CM01%2CN01%2CO01%2CU01%2CWEBUI%2CX01%2CZ02%2CZ03%2CZ04%2C&test=&clientServerAddress=https%3A%2F%2Fcqweb.server.address.com%2Fcqweb%2Flogin&username=user&password=password%21&schema=TN_MP3&userDb=D01"

_WinHttpSendRequest($h_openRequest, Default, $sPostData)
;...
 

You can also pass additional headers as second argument of _WinHttpSendRequest() instead of ten _WinHttpAddRequestHeaders() calls.

edit:

And remove 'Accept-Encoding: gzip, deflate' line unless you really want compressed data.

Edited by trancexx

♡♡♡

.

eMyvnE

Link to post
Share on other sites
  • Replies 947
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

The other day mikeytown2 posted one post in HTTP UDF's thread that got me thinking if there is better (different) method to send requests through the HTTP protocol to HTTP servers. There is Winhttp.d

Yes thanks. But the only valid warning is with unreferenced parameter inside __WinHttpFormUpload. I'll fix that.

Hey Raizeno, try this: #include "WinHttp.au3" $sAddress = "https://api.pushover.net/1/messages.json" $sApiToken = "av26ac2nAXLyPKg2QMy4zf9YcUjz2G" ; <-yours here $sUserKey = "uMQf396GvMgrsDr

Posted Images

Still nothing :/

I've tried to shorten postData with curl to be as short as possible and finally managed to do something like this:

#include "../udf/WinHttp.au3"

$LocalIP = "cqweb.server.address.com"

$hw_open = _WinHttpOpen()

$hw_connect = _WinHttpConnect($hw_open, $LocalIP)

$h_openRequest = _WinHttpOpenRequest($hw_connect, "POST", "cqweb/login")

$headers = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' & @CRLF & _
            'Accept-Language: pl,en-us;q=0.7,en;q=0.3' & @CRLF & _
            'Connection: keep-alive' & @CRLF & _
            'Cookie: schemarepo=TN_MP3; userDb=D01; cqecytusid=Zjnh1Smbfl/MiWNLFGixNg==; JSESSIONID=0000F3DyGHdvfvfTMFHI_WA6q2I:-1' & @CRLF & _
            'Host: cqweb.server.address.com' & @CRLF & _
            'Referer: https://cqweb.server.address.com/cqweb/login' & @CRLF & _
            'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0' & @CRLF & _
            'Content-Type: application/x-www-form-urlencoded' & @CRLF

_WinHttpSendRequest($h_openRequest, $headers, "username=user&password=pass")

_WinHttpReceiveResponse($h_openRequest)
MsgBox(8192, "Headers", _WinHttpQueryHeaders($h_openRequest))

Local $response = _WinHttpReadData($h_openRequest)
While @extended = 8192
    $response &= _WinHttpReadData($h_openRequest)
WEnd
ConsoleWrite(@extended & @CRLF)

MsgBox(8192, "resp", $response)

_WinHttpCloseHandle($h_openRequest)

_WinHttpCloseHandle($hw_connect)

_WinHttpCloseHandle($hw_open)

Headers of response:

 

HTTP/1.1 200 OK

Connection: Keep-Alive

Date: Thu, 23 Jan 2014 09:28:48 GMT

Keep-Alive: timeout=15, max=100

Content-Length: 15574

Content-Type: text/html; charset=UTF-8

Content-Language: ko-KR

Server: IBM_HTTP_Server/6.0.2.27 Apache/2.0.47 (Win32)

Set-Cookie: JSESSIONID=0000QEBn_rKDGIijUiOSyU-ugjo:-1; Path=/

Set-Cookie: cqweb_session=""; Expires=Thu, 01 Dec 1994 16:00:00 GMT;

Path=/cqweb/

 

One thing that could matter - I get redirected from http://cqweb.server.address.com to https://cqweb.server.address.com, however using _WinHttpConnect($hw_open, $LocalIP, $INTERNET_DEFAULT_HTTPS_PORT) results in empty response from server (no headers, no data).

Link to post
Share on other sites

Can't you simply do this:

$hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0")
$hConnect = _WinHttpConnect($hOpen, "https://cqweb.server.address.com")
$sRead = _WinHttpSimpleFormFill($hConnect, "/cqweb/login", _
        "index:0", _ ; first form on the page (is it?)
        "name:username", "user", _
        "name:password", "pass")

ConsoleWrite("!Error = " & @error & @CRLF)
ConsoleWrite($sRead & @CRLF)

_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

You should really just try to explain what you want to do. What, first you login and then navigate to some other page? Is that it?

I can help you with that, but you need to be more concrete.

♡♡♡

.

eMyvnE

Link to post
Share on other sites

Yes, it is the first (and the only) form on the page. Here's its code:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Rational</title>
<script type="text/javascript" src="/cqweb/view/browser/common/common.js" language="JavaScript"></script><link rel="stylesheet" type="text/css" href="/cqweb/view/browser/common/common_adv.css"><script type="text/javascript" src="/cqweb/view/browser/common/cqweb_xsl_strings_en.js" language="JavaScript"></script><script type="text/javascript" src="/cqweb/view/browser/common/javascript_utilities.js" language="JavaScript"></script><script type="text/javascript" src="/cqweb/view/browser/common/utility.js" language="JavaScript"></script><script src="/cqweb/view/browser/common/sniffer.js" type="text/javascript" language="JavaScript"></script><script type="text/javascript" language="JavaScript">
var schemaReposArr  = new Array();
var dbArr           = new Array();
var dbDescArr       = new Array();
var testMode        = "";

schemaReposArr[schemaReposArr.length]="TN_STANDARD";

dbArr["TN_STANDARD"] = new Array();
dbDescArr["TN_STANDARD"] = new Array();

dbArr["TN_STANDARD"][0] = "A01";

dbDescArr["TN_STANDARD"][0] = "Windows Mobile";

dbArr["TN_STANDARD"][1] = "C01";

dbDescArr["TN_STANDARD"][1] = "Overseas R&D Centre";

dbArr["TN_STANDARD"][2] = "D01";

dbDescArr["TN_STANDARD"][2] = "RnD_Europe";

dbArr["TN_STANDARD"][3] = "D02";

dbDescArr["TN_STANDARD"][3] = "G.GSM_Team";

dbArr["TN_STANDARD"][4] = "F01";

dbDescArr["TN_STANDARD"][4] = "RnD_China";

dbArr["TN_STANDARD"][5] = "F02";

dbDescArr["TN_STANDARD"][5] = "China_Team";

dbArr["TN_STANDARD"][6] = "G01";

dbDescArr["TN_STANDARD"][6] = "RnD_NAmerica";

dbArr["TN_STANDARD"][7] = "G02";

dbDescArr["TN_STANDARD"][7] = "Namerica_Team";

dbArr["TN_STANDARD"][8] = "GA01";

dbDescArr["TN_STANDARD"][8] = "RnD_Android";

dbArr["TN_STANDARD"][9] = "GA02";

dbDescArr["TN_STANDARD"][9] = "Andvanced_Team";

dbArr["TN_STANDARD"][10] = "H01";

dbDescArr["TN_STANDARD"][10] = "RnD_SLP";

dbArr["TN_STANDARD"][11] = "H02";

dbDescArr["TN_STANDARD"][11] = "SLP_Team";

dbArr["TN_STANDARD"][12] = "I01";

dbDescArr["TN_STANDARD"][12] = "RnD_Android_3G";

dbArr["TN_STANDARD"][13] = "K01";

dbDescArr["TN_STANDARD"][13] = "RnD_Korea";

dbArr["TN_STANDARD"][14] = "K02";

dbDescArr["TN_STANDARD"][14] = "Korea_Team";

dbArr["TN_STANDARD"][15] = "M01";

dbDescArr["TN_STANDARD"][15] = "Advanced Project DB";

dbArr["TN_STANDARD"][16] = "N01";

dbDescArr["TN_STANDARD"][16] = "Misc.";

dbArr["TN_STANDARD"][17] = "O01";

dbDescArr["TN_STANDARD"][17] = "RnD_Latin_America";

dbArr["TN_STANDARD"][18] = "U01";

dbDescArr["TN_STANDARD"][18] = "RnD_Japan";

dbArr["TN_STANDARD"][19] = "WEBUI";

dbDescArr["TN_STANDARD"][19] = "PC DEV.";

dbArr["TN_STANDARD"][20] = "X01";

dbDescArr["TN_STANDARD"][20] = "S/W Solution";

dbArr["TN_STANDARD"][21] = "Z02";

dbDescArr["TN_STANDARD"][21] = "Training DB";

dbArr["TN_STANDARD"][22] = "Z03";

dbDescArr["TN_STANDARD"][22] = "STAP";

dbArr["TN_STANDARD"][23] = "Z04";

dbDescArr["TN_STANDARD"][23] = "SE Group(Weekly Repo...";

var userNameVal     = "";
var deptedUserName  = "";
var schemaRepoVal   = "";
var userDbVal       = "";
var enableCookies   = "true";
var ssoEnable       = "false";
var ssoUserId       = "";
var ssoLoginLocked  = "false";
function setDbList(schemaRepoId)
{
var j = 1;
document.formLogin.userDb.options.length = 0;
document.formLogin.userDb.options[0] = new Option("Select a database");
for (i=1; i<=dbArr[schemaRepoId].length; i++)
{
document.formLogin.userDb.options[i] = new Option(dbArr[schemaRepoId][i-1]+ ' : ' +dbDescArr[schemaRepoId][i-1], dbArr[schemaRepoId][i-1]);
}
if (userDbVal.length == 0)
{
userDbVal = getCookie("userDb");
}

if (userDbVal.length > 0)
{
var matchIndex = -1;
for (var i=0; i < document.formLogin.userDb.options.length && matchIndex == -1; i++)
{
var optionVal = document.formLogin.userDb.options[i].value;
if (userDbVal == optionVal)
matchIndex = i;
}
if (matchIndex > -1)
document.formLogin.userDb.selectedIndex = matchIndex;
}
else
{
document.formLogin.userDb.selectedIndex = 0;
}

}
function onLoadForm()
{
if (!validBrowser())
{
window.location.href='/cqweb/dct/html/wrongBrowser_en.html';
}
if (ssoEnable == 'true')
{
if (ssoUserId != ''){
userNameVal = ssoUserId;
document.formLogin.username.value = userNameVal;
document.formLogin.password.value = '';
document.formLogin.schema.focus();
disableLoginCredentials();
enableLoginSelections();
enableLoginButton();
}
if (ssoLoginLocked == 'true'){
disableLoginPage();
}
}
else
{
document.formLogin.username.focus();
enableLoginPage();
}

if(enableCookies == 'true')
{
document.formLogin.username.value = deptedUserName;
}

if (schemaRepoVal.length == 0)
schemaRepoVal = getCookie("schemarepo");

if (schemaRepoVal.length > 0)
{
var matchIndex = -1;
var decodeSchema = decodeURIComponent(decodeURIComponent(schemaRepoVal));
for (var i=0; i < document.formLogin.schema.options.length && matchIndex == -1; i++)
{
var optionVal = document.formLogin.schema.options[i].text;
if (decodeSchema == optionVal)
matchIndex = i;
}
if (matchIndex > -1)
document.formLogin.schema.selectedIndex = matchIndex;
}
if (testMode != '1')
{
setDbList(document.formLogin.schema.options[document.formLogin.schema.selectedIndex].text);
}
}
function setCookie(Name, Value)
{
if (enableCookies != 'true')
{
return;
}
var nextYear = new Date();
nextYear.setFullYear(nextYear.getFullYear() + 1);
var expiration = nextYear.toGMTString();
document.cookie = Name + "=" + encodeURIComponent(Value) + ";expires=" + expiration;
}
function getCookie(Name)
{
var value = "";
if (enableCookies != 'true')
{
return value;
}
if (navigator.cookieEnabled)
{
var search = Name + "="
if (document.cookie.length > 0)
{
offset = document.cookie.indexOf(search);
if (offset != -1)
{
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1)
end = document.cookie.length;
value = decodeURIComponent(document.cookie.substring(offset, end))
}
}
}
return value;
}
function submitForm()
{
if ( document.getElementById("clientServerAddress") != null)
document.getElementById("clientServerAddress").value = top.location.href;
if (document.formLogin.schema.options.length <= 0)
{
alert(no_schemaResp_available);
return false;
}
if (testMode != '1' && document.formLogin.userDb.selectedIndex <= 0)
{
alert(select_a_DB_Str);
return false;
}
else if (testMode == '1' && document.formLogin.userDb.value.trim().length <=0)
{
alert(enter_a_DB_Str);
return false;
}
var schemaRepoId = document.formLogin.schema.options[document.formLogin.schema.selectedIndex].text
var userDbs = "";
for (var i = 0; i < dbArr[schemaRepoId].length; i++)
{
userDbs += (dbArr[schemaRepoId][i] + ",");
}
document.formLogin.ratl_userdb.value = userDbs;
var trimmedUserName = document.formLogin.username.value.trim();
document.formLogin.username.value = trimmedUserName;
setCookie("schemarepo", document.formLogin.schema.options[document.formLogin.schema.selectedIndex].text);
if (testMode == '1')
{
setCookie("userDb", document.formLogin.userDb.value);
}
else
{
setCookie("userDb", document.formLogin.userDb.options[document.formLogin.userDb.selectedIndex].value);
}
checkURLParametersFormat(document);
disableLoginButton();
return document.formLogin.submit();
}
function disableLoginPage()
{
disableLoginCredentials();
disableLoginSelections();
disableLoginButton();
}
function disableLoginSelections()
{
document.formLogin.schema.className = 'disabledControl';
document.formLogin.userDb.className = 'disabledControl';
document.formLogin.schema.disabled = 'disabled';
document.formLogin.userDb.disabled = 'disabled';
}
function disableLoginCredentials()
{
document.formLogin.username.className = 'disabledControl';
document.formLogin.password.className = 'disabledControl';
document.formLogin.username.disabled = 'disabled';
document.formLogin.password.disabled = 'disabled';
}
function disableLoginButton()
{
var loginButtonElem = document.getElementById("loginButtonInput");
loginButtonElem.className = 'disabledControl';
loginButtonElem.disabled = 'disabled';
}
function enableLoginPage()
{
enableLoginCredentials();
enableLoginSelections();
enableLoginButton();
}
function enableLoginCredentials()
{
document.formLogin.username.className = '';
document.formLogin.password.className = '';
document.formLogin.username.disabled = false;
document.formLogin.password.disabled = false;
}
function enableLoginSelections()
{
document.formLogin.schema.className = '';
document.formLogin.userDb.className = '';
document.formLogin.schema.disabled = false;
document.formLogin.userDb.disabled = false;
}
function enableLoginButton()
{
var loginButtonElem = document.getElementById("loginButtonInput");
loginButtonElem.className = 'tabactive1';
loginButtonElem.disabled = false;
}
NS4 = (document.layers) ? true : false;
function checkEnter(event)
{
if (document.getElementById("loginButton").style.display == 'none')
return;
var code = 0;
if (NS4)
{
code = event.which;
}
else
{
code = event.keyCode;
}
if (code == 13)
{
submitForm()
}
}

</script>
<style type="text/css" charset="utf-8">/* See license.txt for terms of usage */
/** reset styling **/
.firebugResetStyles {
    z-index: 2147483646 !important;
    top: 0 !important;
    left: 0 !important;
    display: block !important;
    border: 0 none !important;
    margin: 0 !important;
    padding: 0 !important;
    outline: 0 !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 0 !important;
    max-height: none !important;
    position: fixed !important;
    transform: rotate(0deg) !important;
    transform-origin: 50% 50% !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent none !important;
    pointer-events: none !important;
    white-space: normal !important;
}

.firebugBlockBackgroundColor {
    background-color: transparent !important;
}

.firebugResetStyles:before, .firebugResetStyles:after {
    content: "" !important;
}
/**actual styling to be modified by firebug theme**/
.firebugCanvas {
    display: none !important;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
.firebugLayoutBox {
    width: auto !important;
    position: static !important;
}

.firebugLayoutBoxOffset {
    opacity: 0.8 !important;
    position: fixed !important;
}

.firebugLayoutLine {
    opacity: 0.4 !important;
    background-color: #000000 !important;
}

.firebugLayoutLineLeft, .firebugLayoutLineRight {
    width: 1px !important;
    height: 100% !important;
}

.firebugLayoutLineTop, .firebugLayoutLineBottom {
    width: 100% !important;
    height: 1px !important;
}

.firebugLayoutLineTop {
    margin-top: -1px !important;
    border-top: 1px solid #999999 !important;
}

.firebugLayoutLineRight {
    border-right: 1px solid #999999 !important;
}

.firebugLayoutLineBottom {
    border-bottom: 1px solid #999999 !important;
}

.firebugLayoutLineLeft {
    ;
    border-left: 1px solid #999999 !important;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
.firebugLayoutBoxParent {
    border-top: 0 none !important;
    border-right: 1px dashed #E00 !important;
    border-bottom: 1px dashed #E00 !important;
    border-left: 0 none !important;
    position: fixed !important;
    width: auto !important;
}

.firebugRuler{
    position: absolute !important;
}

.firebugRulerH {
    top: -15px !important;
    left: 0 !important;
    width: 100% !important;
    height: 14px !important;
    background: url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%13%88%00%00%00%0E%08%02%00%00%00L%25a%0A%00%00%00%04gAMA%00%00%D6%D8%D4OX2%00%00%00%19tEXtSoftware%00Adobe%20ImageReadyq%C9e%3C%00%00%04%F8I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06V%D5%07%A8r%5D%3D%D9%A6%CAu%F5%25%CF%A2%99%97zNX%60%95%AB%5DUZ%D5%FBR%03%AB%1C%D4k%9F%3F%BB%5C%FF%81a%AE%AB'%7F%F3%EA%FE%F3z%94%AA%D8%DF%5B%01%00%00%00%00%00%00%00%00%00%8E%FB%F3%F2%B1%1B%8DWU%AAT%A9R%A5J%95*U%AAT%A9R%A5J%95*U%AAT%A9R%A5J%95*U%AAT%A9R%A5J%95*U%AAT%A9R%A5J%95*U%AAT%A9R%A5J%95*U%AAT%A9R%A5J%95*UiU%C7%BBe%E7%F3%B9%CB%AAJ%95*U%AAT%A9R%A5J%95*U%AAT%A9R%A5J%95*U%AAT%A9R%A5J%95*U%AAT%A9R%A5J%95*U%AAT%A9R%A5J%95*U%AAT%A9R%A5J%95*U%AAT%A9R%A5*%AAj%FD%C6%D4%5Eo%90%B5Z%ADV%AB%D5j%B5Z%ADV%AB%D5j%B5Z%ADV%AB%D5j%B5Z%ADV%AB%D5j%B5Z%ADV%AB%D5j%B5Z%ADV%AB%D5j%B5Z%ADV%AB%D5j%B5%86%AF%1B%9F%98%DA%EBm%BBV%AB%D5j%B5Z%ADV%AB%D5j%B5Z%ADV%AB%D5j%B5Z%ADV%AB%D5j%B5Z%ADV%AB%D5j%B5Z%ADV%AB%D5j%B5Z%ADV%AB%D5j%B5Z%AD%D6%E4%F58%01%00%00%00%00%00%00%00%00%00%00%00%00%00%40%85%7F%02%0C%008%C2%D0H%16j%8FX%00%00%00%00IEND%AEB%60%82") repeat-x !important;
    border-top: 1px solid #BBBBBB !important;
    border-right: 1px dashed #BBBBBB !important;
    border-bottom: 1px solid #000000 !important;
}

.firebugRulerV {
    top: 0 !important;
    left: -15px !important;
    width: 14px !important;
    height: 100% !important;
    background: url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%0E%00%00%13%88%08%02%00%00%00%0E%F5%CB%10%00%00%00%04gAMA%00%00%D6%D8%D4OX2%00%00%00%19tEXtS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4T%06-%B3E%8B%16-Z%B4h%A9%0C%B3E%8B%16-Z%B4h%A9%0CZf%8B%16-Z%B4h%A9%0CZf%8B%16-Z%B4h%D1R%19f%8B%16-Z%B4h%D1R%19%B4%CC%16-Z%B4h%D1R%19%B4%CC%16-Z%B4h%D1%A2%A52%CC%16-Z%B4h%D1%A2%A52h%99-Z%B4h%D1%A2%A52h%99-Z%B4h%D1%A2EKe%98-Z%B4h%D1%A2EKe%D02%5B%B4h%D1%A2EKe%D02%5B%B4h%D1%A2E%8B%96%CA0%5B%B4h%D1%A2E%8B%96%CA%A0e%B6h%D1%A2E%8B%96%CA%A0e%B6h%D1%A2E%8B%16-%95a%B6h%D1%A2E%8B%16-%95A%CBl%D1%A2E%8B%16-%95A%CBl%D1%A2E%8B%16-Z*%C3l%D1%A2E%8B%16-Z*%83%96%D9%A2E%8B%16-Z*%83%96%D9%A2E%8B%16-Z%B4T%86%D9%A2E%8B%16-Z%B4T%06-%B3E%8B%16-Z%B4%AE%A4%F5%25%C0%00%DE%BF%5C'%0F%DA%B8q%00%00%00%00IEND%AEB%60%82") repeat-y !important;
    border-left: 1px solid #BBBBBB !important;
    border-right: 1px solid #000000 !important;
    border-bottom: 1px dashed #BBBBBB !important;
}

.overflowRulerX > .firebugRulerV {
    left: 0 !important;
}

.overflowRulerY > .firebugRulerH {
    top: 0 !important;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
.fbProxyElement {
    position: fixed !important;
    pointer-events: auto !important;
}
</style></head>
<body onload="onLoadForm()" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<form action="/cqweb/login" method="post" name="formLogin">
<img alt="" src="/cqweb/view/browser/images/shim.gif" height="120" width="1"><input value="/cqweb/main?command=GenerateMainFrame" name="targetUrl" type="hidden"><input value="" name="ratl_userdb" type="hidden"><input value="" name="test" type="hidden"><input value="" id="clientServerAddress" name="clientServerAddress" type="hidden">
<table summary="Login" class="dialogueboxbg" align="center" border="0" cellpadding="0" cellspacing="0" width="355">
<tbody><tr>
<td class="bgwhite"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td class="bgwhite"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="7"></td><td class="bgwhite"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="346"></td><td class="bgwhite"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="7"></td>
</tr>
<tr>
<td class="dialogueboxborder" colspan="4"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td class="dialogueboxborder" rowspan="8"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td>
</tr>
<tr>
<td class="dialogueboxborder" rowspan="8"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td class="dialogueboxhighlight" colspan="4"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td>
</tr>
<tr>
<td colspan="4" align="center" height="24">Please enter your User Name and Password.</td>
</tr>
<tr>
<td><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td>
<table summary="loginTableInner" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="177"></td><td><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="10"></td><td><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="200"></td><td><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td>
</tr>
<tr>
<td class="dialogueboxhighlight" rowspan="10"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td class="dialgbxshadow2" rowspan="10"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td class="dialgbxshadow2"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td class="dialgbxshadow2" rowspan="10"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td class="dialgbxshadow2" colspan="4"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td class="dialgbxshadow2" rowspan="10"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td class="dialogueboxhighlight" rowspan="10"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td>
</tr>
<tr>
<td class="dialogueboxhighlight"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td class="dialogueboxhighlight" colspan="4"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td>
</tr>
<tr>
<td class="bgwhite" rowspan="6" align="center" height="198" valign="top"><img alt="Welcome to Rational ClearQuest Web" src="/cqweb/htdocs/welcome.gif" border="0"></td><td colspan="2"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="2" width="1"></td><td rowspan="6"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td rowspan="7" class="dialogueboxhighlight"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td>
</tr>
<tr>
<td>
&nbsp;
</td><td valign="center">User Name:
<br>
<input class="" value="" onkeypress="checkEnter(event)" maxlength="50" name="username" type="text"></td>
</tr>
<tr>
<td>
&nbsp;
</td><td valign="center">Password:
<br>
<input class="" onkeypress="checkEnter(event)" maxlength="50" name="password" type="password"></td>
</tr>
<tr>
<td>
&nbsp;
</td><td valign="center">Schema Repository:
<br>
<select class="" onchange="if (testMode != '1') setDbList(this.options[this.selectedIndex].text);" name="schema"><option>TN_STANDARD</option></select></td>
</tr>
<tr>
<td>
&nbsp;
</td><td valign="center">Database:
<br>
<select class="" name="userDb"><option>Select a database</option><option value="A01">A01 : Windows Mobile</option><option value="C01">C01 : Overseas R&amp;D Centre</option><option value="D01">D01 : RnD_Europe</option><option value="D02">D02 : G.GSM_Team</option><option value="F01">F01 : RnD_China</option><option value="F02">F02 : China_Team</option><option value="G01">G01 : RnD_NAmerica</option><option value="G02">G02 : Namerica_Team</option><option value="GA01">GA01 : RnD_Android</option><option value="GA02">GA02 : Andvanced_Team</option><option value="H01">H01 : RnD_SLP</option><option value="H02">H02 : SLP_Team</option><option value="I01">I01 : RnD_Android_3G</option><option value="K01">K01 : RnD_Korea</option><option value="K02">K02 : Korea_Team</option><option value="M01">M01 : Advanced Project DB</option><option value="N01">N01 : Misc.</option><option value="O01">O01 : RnD_Latin_America</option><option value="U01">U01 : RnD_Japan</option><option value="WEBUI">WEBUI : PC DEV.</option><option value="X01">X01 : S/W Solution</option><option value="Z02">Z02 : Training DB</option><option value="Z03">Z03 : STAP</option><option value="Z04">Z04 : SE Group(Weekly Repo...</option></select></td>
</tr>
<tr>
<td>
&nbsp;
</td><td id="loginButton" height="32"><input value="&nbsp;Login&nbsp;" onclick="submitForm();" onmouseup="style.border='outset #fff 2px';" onmousedown="style.border='inset #fff 2px';" href="#" name="loginButtonInput" class="tabactive1" style="padding: 2px; height:24px; font-weight: bold;" id="loginButtonInput" type="button"></td>
</tr>
<tr>
<td class="dialgbxshadow2"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td class="dialgbxshadow2" colspan="4"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td>
</tr>
<tr>
<td class="dialogueboxhighlight" colspan="4"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td><td class="dialogueboxhighlight" colspan="4"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td colspan="4" align="center" height="24"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td>
</tr>
<tr>
<td class="dialogueboxmedium" colspan="4"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td>
</tr>
<tr>
<td class="dialogueboxborder" colspan="4"><img alt="" src="/cqweb/view/browser/images/shim.gif" height="1" width="1"></td>
</tr>
</tbody></table>
</form>


</body>
</html>

Your script returns -1 - no form on the page... That is strange. After changing address to http - still the same.

Sorry for not explaining, but I thought it is obvious.

I have a code which using IE.au3 opens "https://cqweb.server.address.com", fills in login information and then submits the form. After submitting it changes sub pages available after login.

I'd love to do the same using WinHttp.au3, as IE.au3 is not as fast and reliable.

Edited by karlkar
Link to post
Share on other sites

What version of the UDF you use? I'm regularly updating this UDF.

 

Form filling function can add cookies (and all other things you want) like this:

$sHeadersToAdd = "Host: cqweb.server.address.com" & @CRLF & _
        "Referer: https://cqweb.server.address.com/cqweb/login" & @CRLF & _
        "Cookie: schemarepo=TN_MP3; userDb=D01; cqecytusid=Zjnh1Smbfl/MiWNLFGixNg==; JSESSIONID=0000F3DyGHdvfvfTMFHI_WA6q2I:-1"

$hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0")
$hConnect = _WinHttpConnect($hOpen, "https://cqweb.server.address.com")
$sRead = _WinHttpSimpleFormFill($hConnect, "/cqweb/login", _
        "index:0", _ ; first form on the page
        "name:username", "user", _
        "name:password", "pass", _
        $sHeadersToAdd)

ConsoleWrite("!Error = " & @error & @CRLF)
ConsoleWrite($sRead & @CRLF)

_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

♡♡♡

.

eMyvnE

Link to post
Share on other sites

Ok, I've been using v 1.6.3.2. I've updated it now.

After that operation there's no error.

$sRead is however the same as source of cqweb/login, so redirect didn't work out.

I've did all steps manually in FireFox, with Firebug enabled and here's the result:

Opening of cqweb/server.address.com/cqweb/login
Request headers:

GET /cqweb/login HTTP/1.1
Host: cqweb.server.address.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: pl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive

Response headers:
HTTP/1.1 200 OK
Date: Fri, 24 Jan 2014 08:50:08 GMT
Server: IBM_HTTP_Server/6.0.2.27 Apache/2.0.47 (Win32)
Content-Length: 15565
Set-Cookie: JSESSIONID=0000ODamLAZtOKLpqfe649tP_8b:-1; Path=/
cqweb_session=""; Expires=Thu, 01 Dec 1994 16:00:00 GMT; Path=/cqweb/
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Content-Language: ko-KR

================================================================================
After submitting form:
Request headers:

POST /cqweb/login HTTP/1.1
Host: cqweb.server.address.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: pl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: https://cqweb.server.address.com/cqweb/login
Cookie: schemarepo=TN_STANDARD; userDb=D01; JSESSIONID=0000ODamLAZtOKLpqfe649tP_8b:-1
Connection: keep-alive


Request data:
clientServerAddress=https://cqweb.server.address.com/cqweb/login
password=pass
ratl_userdb=A01,C01,D01,D02,F01,F02,G01,G02,GA01,GA02,H01,H02,I01,K01,K02,M01,N01,O01,U01,WEBUI,X01,Z02,Z03,Z04,
schema=TN_STANDARD
targetUrl=/cqweb/main?command=GenerateMainFrame
test=
userDb=D01
username=user

Response headers:
HTTP/1.1 302 Found
Date: Fri, 24 Jan 2014 08:51:00 GMT
Server: IBM_HTTP_Server/6.0.2.27 Apache/2.0.47 (Win32)
Location: https://cqweb.server.address.com/cqweb/main?command=GenerateMainFrame&rmsessionid=9e25e42f-e347-4944-9269-d32455752e45
Set-Cookie: cqecytusid=Zjnh1Smbfl/MiWNLFGixNg==; Expires=Sat, 24 Jan 2015 08:51:46 GMT; Path=/cqweb/; Secure
cqweb_session=SNbi_T1GLZPzGTSR6sybkfsKeYwCZcldAdpTtacr; Path=/cqweb/; Secure
Content-Length: 0
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Content-Language: ko-KR

Working cUrl:

curl 'https://cqweb.server.address.com/cqweb/login' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: pl,en-us;q=0.7,en;q=0.3' -H 'Connection: keep-alive' -H 'Cookie: schemarepo=TN_STANDARD; userDb=D01; JSESSIONID=0000ODamLAZtOKLpqfe649tP_8b:-1' -H 'Host: cqweb.server.address.com' -H 'Referer: https://cqweb.server.address.com/cqweb/login' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0' -H 'Content-Type: application/x-www-form-urlencoded' --data 'targetUrl=%2Fcqweb%2Fmain%3Fcommand%3DGenerateMainFrame&ratl_userdb=A01%2CC01%2CD01%2CD02%2CF01%2CF02%2CG01%2CG02%2CGA01%2CGA02%2CH01%2CH02%2CI01%2CK01%2CK02%2CM01%2CN01%2CO01%2CU01%2CWEBUI%2CX01%2CZ02%2CZ03%2CZ04%2C&test=&clientServerAddress=https%3A%2F%2Fcqweb.server.address.com%2Fcqweb%2Flogin&username=user&password=pass&schema=TN_STANDARD&userDb=D01'

My code is now:

#include "../udf/WinHttp.au3"

$LocalIP = "cqweb.server.address.com"

$sHeadersToAdd = "Host: cqweb.server.address.com" & @CRLF & _
        "Referer: https://cqweb.server.address.com/cqweb/login" & @CRLF & _
        "Cookie: schemarepo=TN_MP3; userDb=D01; cqecytusid=Zjnh1Smbfl/MiWNLFGixNg==; JSESSIONID=0000F3DyGHdvfvfTMFHI_WA6q2I:-1" & @CRLF & _
        'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' & @CRLF & _
        'Content-Type: application/x-www-form-urlencoded'

$hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0")
$hConnect = _WinHttpConnect($hOpen, "https://cqweb.server.address.com")
$sRead = _WinHttpSimpleFormFill($hConnect, "/cqweb/login", _
        "index:0", _ ; first form on the page (is it?)
        "name:username", "user", _
        "name:password", "pass", _
        "name:targetUrl", "%2Fcqweb%2Fmain%3Fcommand%3DGenerateMainFrame", _
        "name:clientServerAddress", "https://cqweb.server.address.com/cqweb/login", _
        "name:schema", "TN_STANDARD", _
        "name:userDb", "D01", _
        "name:ratl_userdb", "A01%2CC01%2CD01%2CD02%2CF01%2CF02%2CG01%2CG02%2CGA01%2CGA02%2CH01%2CH02%2CI01%2CK01%2CK02%2CM01%2CN01%2CO01%2CU01%2CWEBUI%2CX01%2CZ02%2CZ03%2CZ04%2C", _
        "name:test", "", _
        "clientServerAddress", "https%3A%2F%2Fcqweb.server.address.com%2Fcqweb%2Flogin&username=user&password=windows98%21&schema=TN_STANDARD&userDb=D01", _
        $sHeadersToAdd)

ConsoleWrite("!Error = " & @error & @CRLF)
ConsoleWrite($sRead & @CRLF)

_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

As a response still /cqweb/login ...

Edited by karlkar
Link to post
Share on other sites

That curl example looks more like this:

$sHeadersToAdd = "Host: cqweb.server.address.com" & @CRLF & _
        "Referer: https://cqweb.server.address.com/cqweb/login" & @CRLF & _
        "Cookie: schemarepo=TN_STANDARD; userDb=D01; JSESSIONID=0000ODamLAZtOKLpqfe649tP_8b:-1" & @CRLF & _
        "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"

$hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0")
$hConnect = _WinHttpConnect($hOpen, "https://cqweb.server.address.com")
$sRead = _WinHttpSimpleFormFill($hConnect, "/cqweb/login", _
        "index:0", _ ; first form on the page
        "name:targetUrl", "/cqweb/main?command=GenerateMainFrame", _ ; this field is optional really
        "name:ratl_userdb", "A01,C01,D01,D02,F01,F02,G01,G02,GA01,GA02,H01,H02,I01,K01,K02,M01,N01,O01,U01,WEBUI,X01,Z02,Z03,Z04,", _
        "name:test", "", _
        "name:clientServerAddress", "https://cqweb.server.address.com/cqweb/login", _
        "name:username", "user", _
        "name:password", "pass", _
        "name:schema", "TN_STANDARD", _
        "name:userDb", "D01", _
        $sHeadersToAdd)

ConsoleWrite("!Error = " & @error & @CRLF)
ConsoleWrite($sRead & @CRLF)

_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
Edited by trancexx

♡♡♡

.

eMyvnE

Link to post
Share on other sites

Yeah! Now response looks much better, as it is:

HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Fri, 24 Jan 2014 12:57:06 GMT
Keep-Alive: timeout=15, max=99
Content-Length: 15313
Content-Type: text/html; charset=UTF-8
Content-Language: ko-KR
Server: IBM_HTTP_Server/6.0.2.27 Apache/2.0.47 (Win32)
Set-Cookie: cqecytusid=Zjnh1Smbfl/MiWNLFGixNg==; Expires=Sat, 24 Jan 2015 12:57:05 GMT; 
Path=/cqweb/; Secure

However I still need rmsessionid parameter that is in given as GET parameter in redirection. (From my previous post):

Response headers:
HTTP/1.1 302 Found
Date: Fri, 24 Jan 2014 08:51:00 GMT
Server: IBM_HTTP_Server/6.0.2.27 Apache/2.0.47 (Win32)
Location: https://cqweb.server.address.com/cqweb/main?command=GenerateMainFrame&rmsessionid=9e25e42f-e347-4944-9269-d32455752e45
Set-Cookie: cqecytusid=Zjnh1Smbfl/MiWNLFGixNg==; Expires=Sat, 24 Jan 2015 08:51:46 GMT; Path=/cqweb/; Secure
cqweb_session=SNbi_T1GLZPzGTSR6sybkfsKeYwCZcldAdpTtacr; Path=/cqweb/; Secure
Content-Length: 0
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Content-Language: ko-KR

In Location: there's rmsessionid parameter, which I cannot obtain otherway then from address. Is there a way of getting that address? Or prevent your functions from redirecting automatically?

There's one thing that is strange... If it is after redirect then /cqweb/main should be loaded, but $sRead contains /cqweb/login

Edited by karlkar
Link to post
Share on other sites

Why do you need that sessionid?

You can disable redirections on request like this:

_WinHttpSetOption($hRequest,$WINHTTP_OPTION_DISABLE_FEATURE,$WINHTTP_DISABLE_REDIRECTS)
 

But before that what do you get if you navigate to /cqweb/main after logging in?

$sHeadersToAdd = "Host: cqweb.server.address.com" & @CRLF & _
        "Referer: https://cqweb.server.address.com/cqweb/login" & @CRLF & _
        "Cookie: schemarepo=TN_STANDARD; userDb=D01; JSESSIONID=0000ODamLAZtOKLpqfe649tP_8b:-1" & @CRLF & _
        "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"

$hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0")
$hConnect = _WinHttpConnect($hOpen, "https://cqweb.server.address.com")
$sRead = _WinHttpSimpleFormFill($hConnect, "/cqweb/login", _
        "index:0", _ ; first form on the page
        "name:ratl_userdb", "A01,C01,D01,D02,F01,F02,G01,G02,GA01,GA02,H01,H02,I01,K01,K02,M01,N01,O01,U01,WEBUI,X01,Z02,Z03,Z04,", _
        "name:test", "", _
        "name:clientServerAddress", "https://cqweb.server.address.com/cqweb/login", _
        "name:username", "user", _
        "name:password", "pass", _
        "name:schema", "TN_STANDARD", _
        "name:userDb", "D01", _
        $sHeadersToAdd)

$hRequest = _WinHttpSimpleSendRequest($hConnect, Default, "/cqweb/main")
$sRead = _WinHttpSimpleReadData($hRequest)


ConsoleWrite($sRead & @CRLF)


_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
$hConnect should have all the necessary cookies attached for user.

♡♡♡

.

eMyvnE

Link to post
Share on other sites

I'm getting sick of it...

When I do it in FireFox:

1. Opening "/cqweb/login"

2. Filling in the form

3. Pressing submit button

4. Waiting for "/cqweb/main?command=GenerateMainFrame&rmsessionid=Whatever" to load

When I will change url to "/cqweb/main" - empty page shows up.

When I will change url to "/cqweb/main?GenerateMainFrame" (without rmsessionid) - "cqweb/login" shows up.

Conclusion: rmsessionid is obligatory and not stored in cookies.

When I do it in AutoIt with following script:

#include "WinHttp.au3"

$sHeadersToAdd = "Host: cqweb.server.address.com" & @CRLF & _
        "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"

$hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0")
$hConnect = _WinHttpConnect($hOpen, "https://cqweb.server.address.com")

$sRead = _WinHttpSimpleFormFill($hConnect, "/cqweb/login", _
        "index:0", _ ; first form on the page
        "name:ratl_userdb", "A01,C01,D01,D02,F01,F02,G01,G02,GA01,GA02,H01,H02,I01,K01,K02,M01,N01,O01,U01,WEBUI,X01,Z02,Z03,Z04,", _
        "name:test", "", _
        "name:clientServerAddress", "https://cqweb.server.address.com/cqweb/login", _
        "name:username", "user", _
        "name:password", "pass", _
        "name:schema", "TN_STANDARD", _
        "name:userDb", "D01", _
        $sHeadersToAdd)

$error = @error
ConsoleWrite("!Error " & $error & @CRLF)
ConsoleWrite(StringLeft($sRead, 1500) & @CRLF)

If $error = 0 Then
    $hRequest = _WinHttpSimpleSendRequest($hConnect, "GET", "/cqweb/main?command=GetEntity&entityDefName=Defect&entityId=34381788")

    ConsoleWrite("Headers = " & _WinhttpQueryHeaders($hRequest) & @CRLF)
    $sRead = _WinHttpSimpleReadData($hRequest)

    ConsoleWrite("Error: " & @error & ", read: " & $sRead & @CRLF)
    _WinHttpCloseHandle($hRequest)
EndIf
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen) 

Output is:

>"D:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\Karex\Desktop\autoit\cqTest.au3" /UserParams    
+>19:23:02 Starting AutoIt3Wrapper v.2.1.3.0 SciTE v.3.3.6.0 ;  Keyboard:00000415  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0415  Keyboard:00000415  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64)
>Running AU3Check (1.54.22.0)  from:D:\Program Files (x86)\AutoIt3
+>19:23:02 AU3Check ended.rc:0
>Running:(3.3.8.1):D:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\Karex\Desktop\autoit\cqTest.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Fri, 24 Jan 2014 18:23:02 GMT
Keep-Alive: timeout=15, max=99
Content-Length: 15303
Content-Type: text/html; charset=UTF-8
Content-Language: ko-KR
Server: IBM_HTTP_Server/6.0.2.27 Apache/2.0.47 (Win32)
Set-Cookie: cqecytusid=Zjnh1Smbfl/MiWNLFGixNg==; Expires=Sat, 24 Jan 2015 18:23:02 GMT; Path=/cqweb/; Secure


!Error 0
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Rational</title>
<script type="text/javascript" src="/cqweb/view/browser/common/common.js" language="JavaScript"></script><script type="text/javascript" src="/cqweb/view/browser/common/cqweb_xsl_strings_en.js" language="JavaScript"></script><script type="text/javascript" src="/cqweb/view/browser/common/javascript_utilities.js" language="JavaScript"></script><script type="text/javascript" src="/cqweb/view/browser/common/utility.js" language="JavaScript"></script><script src="/cqweb/view/browser/common/sniffer.js" type="text/javascript" language="JavaScript"></script><script type="text/javascript" language="JavaScript">
var schemaReposArr  = new Array();
var dbArr           = new Array();
var dbDescArr       = new Array();
var testMode        = "";

schemaReposArr[schemaReposArr.length]="TN_MP3";

dbArr["TN_MP3"] = new Array();
dbDescArr["TN_MP3"] = new Array();

dbArr["TN_MP3"][0] = "A01";

dbDescArr["TN_MP3"][0] = "Windows Mobile";

dbArr["TN_MP3"][1] = "C01";

dbDescArr["TN_MP3"][1] = "Overseas R&D Centre";

dbArr["TN_MP3"][2] = "D01";

dbDescArr["TN_MP3"][2] = "RnD_Europe";

dbArr["TN_MP3"][3] = "D02";

dbDescArr["TN_MP3"][3] = "G.GSM_Team";

dbArr["TN_MP3"][4] = "F01";

dbDescArr["TN_MP3"][4] = "RnD_China";

db
Headers = 
Error: 2, read: 
+>19:23:11 AutoIt3.exe ended.rc:0
>Exit code: 0    Time: 9.806

And one fun thing. I wanted to check what will happen when I will input wrong username and password. The result of the script is the same...

When I've opened the response in FireFox I realised that there's always "Invalid login information" error. My login contains dot, and my password contains special characters like ! or ? maybe they cause some trouble?

 

I've made another test using FireFox - I've opened cqweb/login, cleared cookies and submitted the form with correct login and password. "Invalid login credentials error appeared". So I have to open cqweb/login, and then send the post data...

 

Here is new script:

#include "WinHttp.au3"

$sHeadersToAdd = "Host: cqweb.server.address.com" & @CRLF & _
        "Connection: keep-alive" & @CRLF & _
        "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"

$hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0")
$hConnect = _WinHttpConnect($hOpen, "http://cqweb.server.address.com")

ConsoleWrite("======================================" & @CRLF & @CRLF)

$hRequest = _WinHttpSimpleSendRequest($hConnect, "GET", "/cqweb/login")
_WinHttpReceiveResponse($hRequest)
ConsoleWrite(_WinhttpQueryHeaders($hRequest) & @CRLF)
$sRead = _WinHttpSimpleReadData($hRequest)
ConsoleWrite("!Error " & @error & @CRLF)
If StringInStr($sRead, "Please enter your User Name and Password.") <> 0 Then
    ConsoleWrite("Loaded /cqweb/login" & @CRLF)
EndIf

ConsoleWrite("======================================" & @CRLF & @CRLF)

$hRequest = _WinHttpSimpleSendRequest($hConnect, "POST", "/cqweb/login", Default, "targetUrl%3D%2Fcqweb%2Fmain%3Fcommand%3DGenerateMainFrame%26ratl_userdb%3DA01%2CC01%2CD01%2CD02%2CF01%2CF02%2CG01%2CG02%2CGA01%2CGA02%2CH01%2CH02%2CI01%2CK01%2CK02%2CM01%2CN01%2CO01%2CU01%2CWEBUI%2CX01%2CZ02%2CZ03%2CZ04%2C%26test%3D%26clientServerAddress%3Dhttps%3A%2F%2Fcqweb.server.address.com%2Fcqweb%2Flogin%26username%3Duser%26password%3Dpass98%26schema%3DTN_MP3%26userDb%3DD01", $sHeadersToAdd)
_WinHttpReceiveResponse($hRequest)
ConsoleWrite(_WinhttpQueryHeaders($hRequest) & @CRLF)
$sRead = _WinHttpSimpleReadData($hRequest)
ConsoleWrite("!Error " & @error & @CRLF)
If StringInStr($sRead, "Please enter your User Name and Password.") <> 0 Then
    ConsoleWrite("/cqweb/login" & @CRLF)
EndIf
If StringInStr($sRead, "Invalid") <> 0 Then
    ConsoleWrite("Invalid" & @CRLF)
EndIf

ConsoleWrite("======================================" & @CRLF & @CRLF)

$hRequest = _WinHttpSimpleSendRequest($hConnect, "GET", "/cqweb/main?command=GetEntity&entityDefName=Defect&entityId=34381788")

ConsoleWrite("Headers = " & _WinhttpQueryHeaders($hRequest) & @CRLF)
$sRead = _WinHttpSimpleReadData($hRequest)

ConsoleWrite("Error: " & @error & ", read: " & @CRLF & $sRead & @CRLF)

_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

and the response:

>"D:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\Karex\Desktop\autoit\cqTest.au3" /UserParams    
+>20:39:56 Starting AutoIt3Wrapper v.2.1.3.0 SciTE v.3.3.6.0 ;  Keyboard:00000415  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0415  Keyboard:00000415  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64)
>Running AU3Check (1.54.22.0)  from:D:\Program Files (x86)\AutoIt3
+>20:39:56 AU3Check ended.rc:0
>Running:(3.3.8.1):D:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\Karex\Desktop\autoit\cqTest.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
======================================

HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Fri, 24 Jan 2014 19:39:53 GMT
Keep-Alive: timeout=15, max=100
Content-Length: 15565
Content-Type: text/html; charset=UTF-8
Content-Language: ko-KR
Server: IBM_HTTP_Server/6.0.2.27 Apache/2.0.47 (Win32)
Set-Cookie: JSESSIONID=0000Bmpysmc9VPQszhIejYcAwok:-1; Path=/
Set-Cookie: cqweb_session=""; Expires=Thu, 01 Dec 1994 16:00:00 GMT; Path=/cqweb/


!Error 0
Loaded /cqweb/login
======================================

HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Fri, 24 Jan 2014 19:39:57 GMT
Keep-Alive: timeout=15, max=99
Content-Length: 15565
Content-Type: text/html; charset=UTF-8
Content-Language: ko-KR
Server: IBM_HTTP_Server/6.0.2.27 Apache/2.0.47 (Win32)
Set-Cookie: cqweb_session=""; Expires=Thu, 01 Dec 1994 16:00:00 GMT; Path=/cqweb/


!Error 0
/cqweb/login
======================================

Headers = HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Fri, 24 Jan 2014 19:39:58 GMT
Keep-Alive: timeout=15, max=98
Transfer-Encoding: chunked
Content-Type: text/html;charset=ISO-8859-1
Content-Language: ko-KR
Server: IBM_HTTP_Server/6.0.2.27 Apache/2.0.47 (Win32)


Error: 0, read: 
<html>
<body onLoad="top.window.location='/cqweb/login?/cqweb/main?command=GetEntity&entityDefName=Defect&entityId=34381788'"
</body>
</html>

+>20:40:04 AutoIt3.exe ended.rc:0
>Exit code: 0    Time: 8.615

<body onLoad="top.window.location='/cqweb/login?/cqweb/main?command=GetEntity&entityDefName=Defect&entityId=34381788'" means redirect to cqweb/login...

Note that I've set 

$hConnect = _WinHttpConnect($hOpen, "http://cqweb.server.address.com")

because when I set it to

$hConnect = _WinHttpConnect($hOpen, "https://cqweb.server.address.com")

all I got was:

>"D:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\Karex\Desktop\autoit\cqTest.au3" /UserParams    
+>20:42:06 Starting AutoIt3Wrapper v.2.1.3.0 SciTE v.3.3.6.0 ;  Keyboard:00000415  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0415  Keyboard:00000415  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64)
>Running AU3Check (1.54.22.0)  from:D:\Program Files (x86)\AutoIt3
+>20:42:06 AU3Check ended.rc:0
>Running:(3.3.8.1):D:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\Karex\Desktop\autoit\cqTest.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
======================================


!Error 2
======================================


!Error 2
======================================

Headers = 
Error: 2, read: 

+>20:42:09 AutoIt3.exe ended.rc:0
>Exit code: 0    Time: 3.487
Edited by karlkar
Link to post
Share on other sites

Well, I know the feeling. :)

This code should do exactly the same thing your working curl example does. And I mean exactly exactly.

#include "WinHttp.au3"

$sUser = "user"
$sPass = "pass"

$sHeadersToAdd = "Host: cqweb.server.address.com" & @CRLF & _
        "Referer: https://cqweb.server.address.com/cqweb/login" & @CRLF & _
        "Cookie: schemarepo=TN_STANDARD; userDb=D01; JSESSIONID=0000ODamLAZtOKLpqfe649tP_8b:-1"

$sAction = "https://cqweb.server.address.com/cqweb/login"
Local $sForm = _
        '<form action="' & $sAction & '" method="post">' & _
        '    <input name="targetUrl"/>' & _
        '    <input name="ratl_userdb"/>' & _
        '    <input name="test"/>' & _
        '    <input name="clientServerAddress" />' & _
        '    <input name="username"/>' & _
        '    <input name="password" />' & _
        '    <input name="schema" />' & _
        '    <input name="userDb" />' & _
        '</form>'

$hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0")

$hConnect = $sForm

; Fill form
$sHTML = _WinHttpSimpleFormFill($hConnect, $hOpen, _
        Default, _
        "name:targetUrl", "/cqweb/main?command=GenerateMainFrame", _
        "name:ratl_userdb", "A01,C01,D01,D02,F01,F02,G01,G02,GA01,GA02,H01,H02,I01,K01,K02,M01,N01,O01,U01,WEBUI,X01,Z02,Z03,Z04,", _
        "name:test", "", _
        "name:clientServerAddress", "https://cqweb.server.address.com/cqweb/login", _
        "name:username", $sUser, _
        "name:password", $sPass, _
        "name:schema", "TN_STANDARD", _
        "name:userDb", "D01", _
        $sHeadersToAdd)

If @error Then
    MsgBox(4096, "Error", "Error number = " & @error)
Else
    ConsoleWrite($sHTML & @CRLF)
EndIf
 

If you get "wrong credentials" then I have no idea. Just set correct user name and password.

Edited by trancexx

♡♡♡

.

eMyvnE

Link to post
Share on other sites

I had hope in that code, However... "Invalid login information"... Looks like this page is anti-WinHttp ;)

I've been looking for some test servers that couldallow you test it in real time, however I couldn't...

It's IBM Rational ClearQuest v 7.0.1.10, it can be downloaded and installed locally if you do have time and feel like you can make it.

I'm gonna give up... but only till Monday ;)

Thanks for your help!

Edited by karlkar
Link to post
Share on other sites
  • 2 weeks later...

Hi,

ich have a Problem. When i set $WINHTTP_FLAG_SECURE in _WinHttpOpenRequest then _WinHttpSendRequest dont work an @error = 1.
 

Without $WINHTTP_FLAG_SECURE it works:

#include "WinHttp.au3"

Func _WinHTTP($sDomain)

    Local $hInternet = _WinHttpOpen()
    Local $hConnect = _WinHttpConnect($hInternet, $sDomain)

    Local $hRequest = _WinHttpOpenRequest($hConnect, "POST", "/index.php", Default, Default, Default, $WINHTTP_FLAG_ESCAPE_DISABLE)

    $data = "test";
    $sHeader = "Content-Type: application/x-www-form-urlencoded"


    _WinHttpSendRequest($hRequest, $sHeader, $data)
    _WinHttpReceiveResponse($hRequest)

    Local $data = _WinHttpReadData($hRequest)

    _WinHttpCloseHandle($hRequest)
    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hInternet)

    MsgBox(1, "WinHTTP", $data)
EndFunc   ;==>_WinHTTP

And with $WINHTTP_FLAG_SECURE it dont work:

#include "WinHttp.au3"

Func _WinHTTP($sDomain)

    Local $hInternet = _WinHttpOpen()
    Local $hConnect = _WinHttpConnect($hInternet, $sDomain)

    Local $hRequest = _WinHttpOpenRequest($hConnect, "POST", "/index.php", Default, Default, Default, BitOR($WINHTTP_FLAG_SECURE, $WINHTTP_FLAG_ESCAPE_DISABLE))

    $data = "test";
    $sHeader = "Content-Type: application/x-www-form-urlencoded"


    _WinHttpSendRequest($hRequest, $sHeader, $data)
    _WinHttpReceiveResponse($hRequest)

    Local $data = _WinHttpReadData($hRequest)

    _WinHttpCloseHandle($hRequest)
    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hInternet)

    MsgBox(1, "WinHTTP", $data)
EndFunc   ;==>_WinHTTP
Edited by chipDE
Link to post
Share on other sites

Hello!

It's me again ;)

I was lucky, as admins updated ClearQuest to the next version, which supports REST ;)

However now I have a strange effect. When I call

http://165.213.147.58/cqweb/oslc/repo/TN_STANDARD/db/D01/record/?rcm.name=550898&oslc_cm.properties=Headline,State,Project,Model,Module,Carrier,Severity,Detected_Version,Due_Date,Description,Extra_Info,Notes_Log,Owner&rcm.type=Carrier_Issue&rcm.contentType=application/json

in Firefox, response comes in max 5s.

When I do it with autoit, it very often fails after 60 second timeout, or takes about 30s when succeeds. (Yes - always when succeeds it takes about 30 seconds)

This is strange, isn't it? The same machine, the same connection. Server supports both, basic and oauth authorization, however I'm using basic in both cases.

Please take a look at what wireshark registers (first = request by Mozilla, second = request by AutoIt)

zn2k.png

fh14.png

Edited by karlkar
Link to post
Share on other sites
  • 2 weeks later...

Hi trancexx, can you help me to send this WinHttpSimpleSSLRequest

GET https://go.xero.com/Reports/ExcelReport.aspx?reportId=bb89fa34-4dd9-4cc4-ab9d-11e171502bdf&report=&statement=17e61be5-f96b-478c-8ef1-a41b0bbe33e6&attPage= HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Referer: https://go.xero.com/Reports/report2.aspx?reportId=bb89fa34-4dd9-4cc4-ab9d-11e171502bdf&statement=AE21E0AE-C1B1-4450-A99F-89F13258F6A8&bankAccountID=B890BEF9-7347-4FBF-A539-9B492DDC7EF6&reportClass=BankReconciliation
Accept-Language: en-US,en;q=0.7,id;q=0.3
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Host: go.xero.com
Connection: Keep-Alive
Cookie: NETPROFIT_AUTH=btcajoktczelxoj1ug30t1re; .XeroSignIn=; XERO-LB=755243180.20736.0000; Akamai-UBB=5934112d.0a3a4ddf; .XeroSession=C6BE12EFDCF11CA0D8FF7BECB148E009A5AA32893EA90E16C25E3BFF85D1572141D9338367F9F3ABA0207167EC6D477FB459FF02D6DDC7F5FC795FC6A22048A53FAE65A56FBAFF9948AB8D5FF426FDED6D6B94AFEA794F67E9383C7E717B1A7C35F3809361180D1DB80007FE9B26FC7BA9E92176225136BF86546BBEC3395D9CFF3FF59833DB77AB3BA9712E5C69B5EE9ADA16A6DD06A1EB9E40860A8188CECBBA439DCE81F233DB190E4AA0F230E288F5E84690275B10162A92E6DF1654D163EB09E1B799E70CDBFA82A023DBA58AECFDD90ABDD5CD49E67325F585F181A4193C9B4E4BA64EBEE838474AA2730C09DDB65DD674; OG_TIP_STATE=ON; X-AK-XERO-ID=a2ca6ece-eaab-4b6b-b2f2-9d7972f5c961; X-XRO-FLAG=
Link to post
Share on other sites

The easiest would probably be to use form filling function. Just open session and fill custom form. Also use last argument for the function to pass additional header data (including cookies). You can see example of using form filling function in such manner by following this link -

♡♡♡

.

eMyvnE

Link to post
Share on other sites
  • 2 weeks later...

Hi,

I am trying to use SetCredentials to pass current logged in user credentials without the user having to specify them.

Any clues on how to accomplish this?

This works fine:

_WinHttpSetCredentials($hRequest, $WINHTTP_AUTH_TARGET_SERVER, $WINHTTP_AUTH_SCHEME_NEGOTIATE, "Domain\User_Name", "Password")

But I'm hoping that there is a way to replace "DomainUser_Name" and "Password" based on the logged in user.  Is there a way to tell it to just authenticate over the current logged in account?

When I go to this site in a browser, it works without prompting for credentials and I can see in wireshark that it is passing the "DomainUser_Name" properly.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...