PDA

View Full Version : qnetworkreply show always "Operation canceled" with 200 code



majatu
30th August 2011, 21:17
i made a request to http://yandex.ru/yandsearch?text=123&lr=213 with proxy



{
proxy.setType(QNetworkProxy::HttpProxy);
proxy.setHostName(QString("46.42.44.212"));
proxy.setPort(3128);
QNetworkProxy::setApplicationProxy(proxy);
}


and qwebview



MyNetworkAccessManager *nam = new MyNetworkAccessManager();
nam->setCookieJar(new QNetworkCookieJar());
ui->webView->page()->setNetworkAccessManager(nam);

QWebSettings::globalSettings()->setAttribute(QWebSettings::AutoLoadImages, true);
QWebSettings::globalSettings()->setAttribute(QWebSettings::JavaEnabled, true);
QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptEnabled, true);
QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);

ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks );

ui->webView->setUrl(QUrl("http://yandex.ru/yandsearch?text=123&lr=213"));

for cookies i have my MyNetworkAccessManager in createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData)



if(static_cast<QNetworkRequest::LoadControl>request.attribute(QNetworkRequest::CookieLoadContr olAttribute, QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic)
{
if (this->cookieJar())
{
QList<QNetworkCookie> cookies = this->cookieJar()->cookiesForUrl(request.url());
if (!cookies.isEmpty())
{
myReq.setHeader(QNetworkRequest::CookieHeader, qVariantFromValue(cookies));
}
}
}


and always get same error


"error string: Operation canceled"
"error url: http://yandex.ru/showcaptcha?retpath=http://yandex.ru/yandsearch?text=123&lr=213&t=0/1314734922/b029d1247fd1f0e0111636a2a04cc9f9&cc=1&"
"error status code:200"

where is the problem? i get html web page with error and nothing display

wysota
30th August 2011, 22:53
Does it work properly if you don't use the proxy?

majatu
31st August 2011, 07:32
Yes, without proxy everything is ok. But point is to use connection only with proxy, because of ip address. And without proxy i don't have redirect to captcha page.

here is sniffer 1-st request


GET http://yandex.ru/yandsearch?text=123&lr=213 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Host: yandex.ru
Connection: Keep-Alive
Accept-Encoding: gzip
Accept-Language: ru-RU,en,*



HTTP/1.1 302 Found
Location: http://yandex.ru/showcaptcha?retpath=http%3A//yandex.ru/yandsearch%3Ftext%3D123%26lr%3D213&t=0/1314772040/cf38cf989d28e76e7da71a00690186d6&cc=1&
Set-Cookie: spravka=dD0xMjgzMjM2MDQwO2k9NDYuNDIuNDQuMjEyO3U9MT I4MzIzNjA0MDk4OTMzMzI4MDtoPTdmMzUxNWJlMTBkYTQ5ZGZi NGE4ZTkyZjY0OWZkY2M2; domain=.yandex.ru; path=/; expires=Fri, 30-Sep-2011 06:27:20 GMT
Proxy-Connection: Close

here is sniffer 2-nd request


GET http://yandex.ru/showcaptcha?retpath=http%3A//yandex.ru/yandsearch%3Ftext%3D123%26lr%3D213&t=0/1314772040/cf38cf989d28e76e7da71a00690186d6&cc=1& HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Host: yandex.ru
Cookie: spravka=dD0xMjgzMjM2MDQwO2k9NDYuNDIuNDQuMjEyO3U9MT I4MzIzNjA0MDk4OTMzMzI4MDtoPTdmMzUxNWJlMTBkYTQ5ZGZi NGE4ZTkyZjY0OWZkY2M2
Connection: Keep-Alive
Accept-Encoding: gzip
Accept-Language: ru-RU,en,*



HTTP/1.1 200 OK
Content-Length: 8706
Proxy-Connection: Close

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html id="nojs" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<!--[if gt IE 7]><!-->
<link rel="stylesheet" href="/captcha/_index.css" type="text/css" />
<!--<![endif]-->
<!--[if lt IE 8]><link rel=stylesheet href="/captcha/_index.ie.css"><![endif]-->
<!--<link rel="shortcut icon" href="/captcha/favicon.ico" />-->

<script type="text/javascript">
function ShowText() {
var d = document.getElementById("id_captcha_text");
d.style.display = (d.style.display == 'block') ? '' : 'block';

}
</script>
<title>....!</title>
</head>

<body class="b-page">
<table class="l-head l-head_type_userpic">
<tr>
<td class="l-head__g"></td>

<td class="l-head__l">
<div class="b-head-logo">
<div class="b-head-logo__logo">
<a class="b-head-logo__link" href=
"http://www.yandex.ru"><img class="b-head-logo__img"
border="0" alt="............" src=
"http://yandex.st/lego/_/X31pO5JJJKEifJ7sfvuf3mGeD_8.png" /></a>
</div>
</div>
</td>

<td class="l-head__gl"></td>

<td class="l-head__c">
<table class="b-head-tabs g-js">
<tr>
<td>&nbsp;</td>
</tr>
</table>

<div class="b-head-line">
<strong class="b-head-name">.......</strong>
</div>

<div class="b-head-menu">
<table class="b-hmenu">
<tr>
<td></td>
</tr>
</table>
</div>
</td>

<td class="l-head__gr"></td>

<td class="l-head__r">
<table class="b-head-userinfo">
<tr>
<td class="b-head-userinfo__td"></td>
</tr>

<tr>
<td class="b-head-userinfo__td" colspan="2"></td>
</tr>

<tr>
<td class="b-head-userinfo__td" colspan="2"></td>
</tr>

<tr>
<td class="b-head-userinfo__td" colspan="2"></td>
</tr>
</table>
</td>

<td class="l-head__g"></td>
</tr>
</table>

<table class="l-page l-page_layout_16-60-16">
<tr>
<td class="l-page__gap"></td>

<td class="l-page__left"></td>

<td class="l-page__center">
<div class="b-static-text">
<p>...... .......... ........, .... .............., ...................... .. ............
IP-............, ............ .... ............................. .... ........ .............. ....
.................. ................ .......................... ............ .. .............</p>

<p>.......... .................... .........., ...................., .............. .......... .. ................ .. ........
.......... .. .............. .......................</p>

<div style="color: red; font-weight: bold">

</div>

<div class="b-captcha">
<form action="http://yandex.ru/checkcaptcha" method="GET">
<input name="key" type="hidden" value="40KqcHZOa3NaotpMJvfQ3HxVWdYpBkf5_0/1314772040/cf38cf989d28e76e7da71a00690186d6_6f4b56a83b1d9a528 37c261a67aa3912">
<input name="retpath" type="hidden" value="http%3A//yandex.ru/yandsearch%3Ftext%3D123%26lr%3D213">

<table class="b-captcha__layout">
<tr>
<td><img src="http://yandex.ru/captchaimg?aHR0cDovL3UuY2FwdGNoYS55YW5kZXgubmV0L2l tYWdlP2tleT00MEtxY0haT2EzTmFvdHBNSnZmUTNIeFZXZFlwQ mtmNQ,,_0/1314772040/cf38cf989d28e76e7da71a00690186d6_af1a3fd751282b35d e22f9dfde1b2bbf" class="b-captcha__image" /></td>

<td><a href="javascript:void(0)" onClick="location.reload()">................ ............
..........</a></td>

<td class="b-captcha__layout__g"></td>

<td class="b-captcha__layout__r"><a href=
"http://xml.yandex.ru/" class=
"b-captcha__xml-link">.............XML</a> ............ ......
.............. ..............</td>
</tr>

<tr>
<td><input name="rep" id="rep-id" class=
"b-captcha__input" autocomplete="off" />
</td>

<td colspan="3"><input type="submit" value=
".................." class="b-captcha__submit" /></td>
</tr>
</table>
</form>
</div>
<h4><a href="javascript:void(0)" class="b-captcha-text-link" style="text-decoration:none;border-bottom:1px dotted" onClick="ShowText();">............ ......

..................?</a></h4>

<div class="b-captcha__text" id="id_captcha_text">
<p>................, ............................ .............. ...................... .... ......,
.. .............. ........................, .................... .. ........ .. ............ ..
........ IP-............. .. ........ ............ ...... .................... ........ ......
............ .......... .. .........., .......... ........ .... ................ ...... ..
............ ................ .... ............ .........................., .................. ..
.............. IP. .. ........ ............ ................ .. ............ .... ............
.................... ...... .. .............. ...................... ...............</p>

<p>................, .... ................ .............. .................... ..................
................ ............ ............. .........................., ..............
.................... .... ........ ........................ .................... .. .............. ....
.................... .................., .... ...................... ..............................
.................... .......................... ...... ........ .......... ................
<a href="http://xml.yandex.ru" title=
"............ / XML">.............XML</a>.</p>

<p>................, ...... .. .......... ................ ......................
...................., .............. .......... ................ ............................
.............. .. ............. .. ........ ............ ...................... ......
.................. .....</p>

<p>.......... ................, ...... ...... .................. .............. .............. ...
....................-.................., ........................ ...... .................. ......
.......... ..................... ................, ...... .......... .................. ..............
.... .............. .............., ................, ........................ ................
<a href="http://www.freedrweb.com/?lng=ru">CureIt</a>
.... ..Dr.Web...</p>

<p>........ .. ...... ................ ................ ...... ........ .... ............
............ ............ .......... ............ .................., ............................
<a href=
"http://feedback.yandex.ru/?from=captcha">............
................ ..........</a>.</p>
</div>
</div>
</td>

<td class="l-page__gap-right"></td>

<td class="l-page__right"></td>

<td class="l-page__gap"></td>
</tr>
</table>

<div class="b-foot">
<table class="b-foot__layout">
<tr>
<td class="b-foot__layout__gap"></td>

<td class=
"b-foot__layout__column b-foot__layout__column_left"></td>

<td class="b-foot__layout__column">
<div class="b-foot__links">
<a class="b-foot__link" href=
"http://feedback.yandex.ru/?from=captcha">................&nbsp;..........</a>
</div>
</td>

<td class=
"b-foot__layout__column b-foot__layout__column_right">
<div class="b-copyright">
..&nbsp;1997...2011 ..<a class="b-copyright__link" href=
"http://www.yandex.ru">............</a>..
</div>
</td>

<td class="b-foot__layout__gap"></td>
</tr>
</table>
</div>
</body>
</html>

majatu
1st September 2011, 14:29
up up up up

majatu
5th September 2011, 16:15
up up up up

majatu
12th September 2011, 12:05
up up up up

wysota
12th September 2011, 12:23
Did you check the difference between what a regular browser sends and what your application sends? Did you check the difference between what a regular browser receives from the server and what your application receives?