複製鏈接
請複製以下鏈接發送給好友

CHttpConnection

鎖定
CHttpConnection是一種類,包含一個構造函數和一個成員函數OpenRequest,使用HTTP協議來管理與服務器的連接。
外文名
CHttpConnection
定    義
一種
類    型
MFC類CHttpConnection管理與HTTP服務器的連接。HTTP是用MFCWinInet類實現的三個Internet服務器協議之中的一個。
要與一個HTTP服務器通訊,必須先構造一個CInternetSession的實例,然後構造一個CHttpConnection對象。不能直接構造一個CHttpConnection對象,而是調用CInternetSession::GetHttpConnection,創建CHttpConnection對象並返回其指針。
#include <afxinet.h>
eg.
if(AfxParseURL(URL,server_type,strServer,path,port))
{
try{
CInternetSession * m_inernetSession = new CinternetSession();
CHttpConnection * m_httpConnection = m_inernetSession->GetHttpConnection( strServer,
m_dwTransferMode,
port,
NULL,
NULL );
CHttpFile * m_httpfile = m_httpConnection ->OpenRequest();
//使用ChttpFile建立發送的Http報文
if(m_httpfile != NULL)
{
return true;
}
}
}