Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CHttpConnection not working

Status
Not open for further replies.

zulfi1234

Instructor
Jul 2, 2000
32
PK
The following&nbsp;&nbsp;program works fine with OpenURL but does not read file when worked with CHttpConnection. It catches the exception & does not come in the read part.<br>Can somebody please help me?<br>Zulfi.<br><br><br>void CQueryDlg::OnOK() <br>{<br> // TODO: Add extra validation here<br> const&nbsp;&nbsp;CString&nbsp;&nbsp;http = &quot;<A HREF=" TARGET="_new"> UpdateData(TRUE);<br> m_out = &quot;&quot;;<br> UpdateData(FALSE);<br> TryURL(http + m_Host);<br> TryURL(http + &quot;<A HREF=" TARGET="_new"> + m_Host);<br> CDialog::OnOK();<br>}<br><br>void CQueryDlg::TryURL(CString URL)<br>{<br> m_out = &quot;Trying &quot; + URL + &quot;\r\n&quot;;<br> UpdateData(FALSE);<br><br> CInternetSession&nbsp;&nbsp;sess;<br> CHttpConnection* pHttpConnect = NULL;<br> CHttpFile* pFile = NULL;<br><br> try {<br> pHttpConnect = sess.GetHttpConnection(URL);<br> pFile = pHttpConnect-&gt;OpenRequest(CHttpConnection::HTTP_VERB_GET, &quot;/&quot;);<br> pFile-&gt;SendRequest();<br> }<br> catch(CInternetException* pEx) {<br> pFile = NULL;<br> pEx-&gt;Delete();<br> }<br><br> if (pFile) {<br> CString&nbsp;&nbsp;line;<br> for (int i=0; i&lt;600 && pFile-&gt;ReadString(line); i++)<br> m_out += line + &quot;\r\n&quot;;<br> pFile-&gt;Close();<br> delete pFile;<br> }<br> <br> if (pHttpConnect != NULL)<br> delete&nbsp;&nbsp;pHttpConnect;<br>}<br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top