<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=276078&amp;view=findpost&amp;p=2299741</guid>
        <pubDate>Sat, 27 Jun 2009 14:09:07 +0000</pubDate>
        <title>Подключиться по HTTP и определить код который вернул сервер</title>
        <link>https://forum.sources.ru/index.php?showtopic=276078&amp;view=findpost&amp;p=2299741</link>
        <description><![CDATA[vtg: С первым вопросом разобрался. Не хватало SendRequest.<br>Остался второй.<br>Что передавать вторым параметром в OpenRequest, чтобы код обращался к объекту к которому обращается браузер при вводе www.yandex.ru (или любго другого адреса), т. к. звестен только URL?]]></description>
        <author>vtg</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=276078&amp;view=findpost&amp;p=2299716</guid>
        <pubDate>Sat, 27 Jun 2009 12:38:31 +0000</pubDate>
        <title>Подключиться по HTTP и определить код который вернул сервер</title>
        <link>https://forum.sources.ru/index.php?showtopic=276078&amp;view=findpost&amp;p=2299716</link>
        <description><![CDATA[vtg: Нужно подключиться к URL по HTTP и определить код который вернул сервер.<br>
Делаю так<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;&nbsp; &nbsp;// 1) Starting session</div><div class="code_line">&nbsp;&nbsp; &nbsp;CInternetSession *pInternetSession = new CInternetSession();</div><div class="code_line">&nbsp;&nbsp; &nbsp;if(pInternetSession) //Fail</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// 2) Try to connect</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;CHttpConnection *pHttpConnection = pInternetSession -&#62; GetHttpConnection(_T(&quot;www.yandex.ru&quot;));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if(pHttpConnection)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DWORD dwRet;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TCHAR &nbsp;msg[1024];</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CHttpFile *pHttpFile = pHttpConnection -&#62; OpenRequest(NULL, _T(&quot;*&quot;));</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pHttpFile -&#62; QueryInfoStatusCode(dwRet);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wsprintf(msg, _T(&quot;%d&quot;), dwStatusCode);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MessageBox(0, msg, 0,MB_OK);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pHttpConnection -&#62; Close();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AfxMessageBox(_T(&quot;GetHttpConnection fail&quot;), MB_OK);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// 3) Close connection</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;pInternetSession -&#62; Close();</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;AfxMessageBox(_T(&quot;CInternetSession fail&quot;), MB_OK);</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
dwStatusCode получается всегда 0.<br>
Как правильно? Что передавать вторым параметром в OpenRequest, чтобы код обращался к объекту к которому обращается браузер при вводе www.yandex.ru, т. к. звестен только URL?]]></description>
        <author>vtg</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      </channel>
      </rss>
	