Results 1 to 7 of 7

Thread: qnetworkreply show always "Operation canceled" with 200 code

  1. #1
    Join Date
    Mar 2009
    Posts
    9
    Thanks
    1

    Default qnetworkreply show always "Operation canceled" with 200 code

    i made a request to http://yandex.ru/yandsearch?text=123&lr=213 with proxy

    Qt Code:
    1. {
    2. proxy.setType(QNetworkProxy::HttpProxy);
    3. proxy.setHostName(QString("46.42.44.212"));
    4. proxy.setPort(3128);
    5. QNetworkProxy::setApplicationProxy(proxy);
    6. }
    To copy to clipboard, switch view to plain text mode 

    and qwebview

    Qt Code:
    1. MyNetworkAccessManager *nam = new MyNetworkAccessManager();
    2. nam->setCookieJar(new QNetworkCookieJar());
    3. ui->webView->page()->setNetworkAccessManager(nam);
    4.  
    5. QWebSettings::globalSettings()->setAttribute(QWebSettings::AutoLoadImages, true);
    6. QWebSettings::globalSettings()->setAttribute(QWebSettings::JavaEnabled, true);
    7. QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptEnabled, true);
    8. QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
    9.  
    10. ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    11.  
    12. ui->webView->setUrl(QUrl("http://yandex.ru/yandsearch?text=123&lr=213"));
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. if(static_cast<QNetworkRequest::LoadControl>request.attribute(QNetworkRequest::CookieLoadControlAttribute, QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic)
    2. {
    3. if (this->cookieJar())
    4. {
    5. QList<QNetworkCookie> cookies = this->cookieJar()->cookiesForUrl(request.url());
    6. if (!cookies.isEmpty())
    7. {
    8. myReq.setHeader(QNetworkRequest::CookieHeader, qVariantFromValue(cookies));
    9. }
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    and always get same error

    Qt Code:
    1. "error string: Operation canceled"
    2. "error url: http://yandex.ru/showcaptcha?retpath=http://yandex.ru/yandsearch?text=123&lr=213&t=0/1314734922/b029d1247fd1f0e0111636a2a04cc9f9&cc=1&"
    3. "error status code:200"
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qnetworkreply show always "Operation canceled" with 200 code

    Does it work properly if you don't use the proxy?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2009
    Posts
    9
    Thanks
    1

    Default Re: qnetworkreply show always "Operation canceled" with 200 code

    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

    Qt Code:
    1. GET http://yandex.ru/yandsearch?text=123&lr=213 HTTP/1.1
    2. User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
    3. Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    4. Host: yandex.ru
    5. Connection: Keep-Alive
    6. Accept-Encoding: gzip
    7. Accept-Language: ru-RU,en,*
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. HTTP/1.1 302 Found
    2. Location: http://yandex.ru/showcaptcha?retpath=http%3A//yandex.ru/yandsearch%3Ftext%3D123%26lr%3D213&t=0/1314772040/cf38cf989d28e76e7da71a00690186d6&cc=1&
    3. Set-Cookie: spravka=dD0xMjgzMjM2MDQwO2k9NDYuNDIuNDQuMjEyO3U9MTI4MzIzNjA0MDk4OTMzMzI4MDtoPTdmMzUxNWJlMTBkYTQ5ZGZiNGE4ZTkyZjY0OWZkY2M2; domain=.yandex.ru; path=/; expires=Fri, 30-Sep-2011 06:27:20 GMT
    4. Proxy-Connection: Close
    To copy to clipboard, switch view to plain text mode 

    here is sniffer 2-nd request

    Qt Code:
    1. GET http://yandex.ru/showcaptcha?retpath=http%3A//yandex.ru/yandsearch%3Ftext%3D123%26lr%3D213&t=0/1314772040/cf38cf989d28e76e7da71a00690186d6&cc=1& HTTP/1.1
    2. User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
    3. Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    4. Host: yandex.ru
    5. Cookie: spravka=dD0xMjgzMjM2MDQwO2k9NDYuNDIuNDQuMjEyO3U9MTI4MzIzNjA0MDk4OTMzMzI4MDtoPTdmMzUxNWJlMTBkYTQ5ZGZiNGE4ZTkyZjY0OWZkY2M2
    6. Connection: Keep-Alive
    7. Accept-Encoding: gzip
    8. Accept-Language: ru-RU,en,*
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. HTTP/1.1 200 OK
    2. Content-Length: 8706
    3. Proxy-Connection: Close
    4.  
    5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    6. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    7.  
    8. <html id="nojs" xmlns="http://www.w3.org/1999/xhtml">
    9. <head>
    10. <meta name="MSSmartTagsPreventParsing" content="true" />
    11. <meta http-equiv="Content-Type" content=
    12. "text/html; charset=utf-8" />
    13. <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    14. <!--[if gt IE 7]><!-->
    15. <link rel="stylesheet" href="/captcha/_index.css" type="text/css" />
    16. <!--<![endif]-->
    17. <!--[if lt IE 8]><link rel=stylesheet href="/captcha/_index.ie.css"><![endif]-->
    18. <!--<link rel="shortcut icon" href="/captcha/favicon.ico" />-->
    19.  
    20. <script type="text/javascript">
    21. function ShowText() {
    22. var d = document.getElementById("id_captcha_text");
    23. d.style.display = (d.style.display == 'block') ? '' : 'block';
    24.  
    25. }
    26. </script>
    27. <title>....!</title>
    28. </head>
    29.  
    30. <body class="b-page">
    31. <table class="l-head l-head_type_userpic">
    32. <tr>
    33. <td class="l-head__g"></td>
    34.  
    35. <td class="l-head__l">
    36. <div class="b-head-logo">
    37. <div class="b-head-logo__logo">
    38. <a class="b-head-logo__link" href=
    39. "http://www.yandex.ru"><img class="b-head-logo__img"
    40. border="0" alt="............" src=
    41. "http://yandex.st/lego/_/X31pO5JJJKEifJ7sfvuf3mGeD_8.png" /></a>
    42. </div>
    43. </div>
    44. </td>
    45.  
    46. <td class="l-head__gl"></td>
    47.  
    48. <td class="l-head__c">
    49. <table class="b-head-tabs g-js">
    50. <tr>
    51. <td>&nbsp;</td>
    52. </tr>
    53. </table>
    54.  
    55. <div class="b-head-line">
    56. <strong class="b-head-name">.......</strong>
    57. </div>
    58.  
    59. <div class="b-head-menu">
    60. <table class="b-hmenu">
    61. <tr>
    62. <td></td>
    63. </tr>
    64. </table>
    65. </div>
    66. </td>
    67.  
    68. <td class="l-head__gr"></td>
    69.  
    70. <td class="l-head__r">
    71. <table class="b-head-userinfo">
    72. <tr>
    73. <td class="b-head-userinfo__td"></td>
    74. </tr>
    75.  
    76. <tr>
    77. <td class="b-head-userinfo__td" colspan="2"></td>
    78. </tr>
    79.  
    80. <tr>
    81. <td class="b-head-userinfo__td" colspan="2"></td>
    82. </tr>
    83.  
    84. <tr>
    85. <td class="b-head-userinfo__td" colspan="2"></td>
    86. </tr>
    87. </table>
    88. </td>
    89.  
    90. <td class="l-head__g"></td>
    91. </tr>
    92. </table>
    93.  
    94. <table class="l-page l-page_layout_16-60-16">
    95. <tr>
    96. <td class="l-page__gap"></td>
    97.  
    98. <td class="l-page__left"></td>
    99.  
    100. <td class="l-page__center">
    101. <div class="b-static-text">
    102. <p>...... .......... ........, .... .............., ...................... .. ............
    103. IP-............, ............ .... ............................. .... ........ .............. ....
    104. .................. ................ .......................... ............ .. .............</p>
    105.  
    106. <p>.......... .................... .........., ...................., .............. .......... .. ................ .. ........
    107. .......... .. .............. .......................</p>
    108.  
    109. <div style="color: red; font-weight: bold">
    110.  
    111. </div>
    112.  
    113. <div class="b-captcha">
    114. <form action="http://yandex.ru/checkcaptcha" method="GET">
    115. <input name="key" type="hidden" value="40KqcHZOa3NaotpMJvfQ3HxVWdYpBkf5_0/1314772040/cf38cf989d28e76e7da71a00690186d6_6f4b56a83b1d9a52837c261a67aa3912">
    116. <input name="retpath" type="hidden" value="http%3A//yandex.ru/yandsearch%3Ftext%3D123%26lr%3D213">
    117.  
    118. <table class="b-captcha__layout">
    119. <tr>
    120. <td><img src="http://yandex.ru/captchaimg?aHR0cDovL3UuY2FwdGNoYS55YW5kZXgubmV0L2ltYWdlP2tleT00MEtxY0haT2EzTmFvdHBNSnZmUTNIeFZXZFlwQmtmNQ,,_0/1314772040/cf38cf989d28e76e7da71a00690186d6_af1a3fd751282b35de22f9dfde1b2bbf" class="b-captcha__image" /></td>
    121.  
    122. <td><a href="javascript:void(0)" onClick="location.reload()">................ ............
    123. ..........</a></td>
    124.  
    125. <td class="b-captcha__layout__g"></td>
    126.  
    127. <td class="b-captcha__layout__r"><a href=
    128. "http://xml.yandex.ru/" class=
    129. "b-captcha__xml-link">.............XML</a> ............ ......
    130. .............. ..............</td>
    131. </tr>
    132.  
    133. <tr>
    134. <td><input name="rep" id="rep-id" class=
    135. "b-captcha__input" autocomplete="off" />
    136. </td>
    137.  
    138. <td colspan="3"><input type="submit" value=
    139. ".................." class="b-captcha__submit" /></td>
    140. </tr>
    141. </table>
    142. </form>
    143. </div>
    144. <h4><a href="javascript:void(0)" class="b-captcha-text-link" style="text-decoration:none;border-bottom:1px dotted" onClick="ShowText();">............ ......
    145.  
    146. ..................?</a></h4>
    147.  
    148. <div class="b-captcha__text" id="id_captcha_text">
    149. <p>................, ............................ .............. ...................... .... ......,
    150. .. .............. ........................, .................... .. ........ .. ............ ..
    151. ........ IP-............. .. ........ ............ ...... .................... ........ ......
    152. ............ .......... .. .........., .......... ........ .... ................ ...... ..
    153. ............ ................ .... ............ .........................., .................. ..
    154. .............. IP. .. ........ ............ ................ .. ............ .... ............
    155. .................... ...... .. .............. ...................... ...............</p>
    156.  
    157. <p>................, .... ................ .............. .................... ..................
    158. ................ ............ ............. .........................., ..............
    159. .................... .... ........ ........................ .................... .. .............. ....
    160. .................... .................., .... ...................... ..............................
    161. .................... .......................... ...... ........ .......... ................
    162. <a href="http://xml.yandex.ru" title=
    163. "............ / XML">.............XML</a>.</p>
    164.  
    165. <p>................, ...... .. .......... ................ ......................
    166. ...................., .............. .......... ................ ............................
    167. .............. .. ............. .. ........ ............ ...................... ......
    168. .................. .....</p>
    169.  
    170. <p>.......... ................, ...... ...... .................. .............. .............. ...
    171. ....................-.................., ........................ ...... .................. ......
    172. .......... ..................... ................, ...... .......... .................. ..............
    173. .... .............. .............., ................, ........................ ................
    174. <a href="http://www.freedrweb.com/?lng=ru">CureIt</a>
    175. .... ..Dr.Web...</p>
    176.  
    177. <p>........ .. ...... ................ ................ ...... ........ .... ............
    178. ............ ............ .......... ............ .................., ............................
    179. <a href=
    180. "http://feedback.yandex.ru/?from=captcha">............
    181. ................ ..........</a>.</p>
    182. </div>
    183. </div>
    184. </td>
    185.  
    186. <td class="l-page__gap-right"></td>
    187.  
    188. <td class="l-page__right"></td>
    189.  
    190. <td class="l-page__gap"></td>
    191. </tr>
    192. </table>
    193.  
    194. <div class="b-foot">
    195. <table class="b-foot__layout">
    196. <tr>
    197. <td class="b-foot__layout__gap"></td>
    198.  
    199. <td class=
    200. "b-foot__layout__column b-foot__layout__column_left"></td>
    201.  
    202. <td class="b-foot__layout__column">
    203. <div class="b-foot__links">
    204. <a class="b-foot__link" href=
    205. "http://feedback.yandex.ru/?from=captcha">................&nbsp;..........</a>
    206. </div>
    207. </td>
    208.  
    209. <td class=
    210. "b-foot__layout__column b-foot__layout__column_right">
    211. <div class="b-copyright">
    212. ..&nbsp;1997...2011 ..<a class="b-copyright__link" href=
    213. "http://www.yandex.ru">............</a>..
    214. </div>
    215. </td>
    216.  
    217. <td class="b-foot__layout__gap"></td>
    218. </tr>
    219. </table>
    220. </div>
    221. </body>
    222. </html>
    To copy to clipboard, switch view to plain text mode 
    Last edited by majatu; 31st August 2011 at 07:32.

  4. #4
    Join Date
    Mar 2009
    Posts
    9
    Thanks
    1

    Default Re: qnetworkreply show always "Operation canceled" with 200 code

    up up up up

  5. #5
    Join Date
    Mar 2009
    Posts
    9
    Thanks
    1

    Default Re: qnetworkreply show always "Operation canceled" with 200 code

    up up up up

  6. #6
    Join Date
    Mar 2009
    Posts
    9
    Thanks
    1

    Default Re: qnetworkreply show always "Operation canceled" with 200 code

    up up up up

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qnetworkreply show always "Operation canceled" with 200 code

    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 4
    Last Post: 3rd November 2011, 08:30
  2. the pure virtual method "abort" in QNetworkReply
    By mavenlin in forum Qt Programming
    Replies: 2
    Last Post: 9th July 2011, 10:01
  3. protocol "" is unknown QNetworkReply
    By mahadevans87 in forum Qt Programming
    Replies: 1
    Last Post: 11th May 2011, 12:55
  4. Store several "QNetworkReply" in a QMap !
    By fitzy in forum Qt Programming
    Replies: 3
    Last Post: 29th November 2009, 11:50
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.