The following table shows the steps you might perform in a typical HTTP client application:
Your goal Actions you take Effects
Begin an HTTP session.
Create a CInternetSession object.
Initializes WinInet and connects to server.
Connect to an HTTP server.
Use CInternetSession::GetHttpConnection.
Returns a CHttpConnection object.
Open an HTTP request.
Use CHttpConnection::OpenRequest.
Returns a CHttpFile object.
Send an HTTP request.
Use CHttpFile::AddRequestHeaders and CHttpFile::SendRequest.
Finds the file. Returns FALSE if the file is not found.
Read from the file.
Use CHttpFile.
Reads the specified number of bytes using a buffer you supply.
Handle exceptions.
Use the CInternetException class.
Handles all common Internet exception types.
End the HTTP session.
Dispose of the CInternetSession object.
Automatically cleans up open file handles and connections.
下表显示了在典型的HTTP客户端应用程序中可能执行的步骤: 您的目标操作您采取的效果 开始HTTP会话 创建CInternetSession对象。 初始化WinInet并连接到服务器。 连接到HTTP服务器。 使用CInternetSession :: GetHttpConnection。 返回一个CHttpConnection对象。 打开HTTP请求 使用CHttpConnection :: OpenRequest。 返回一个CHttpFile对象。 发送HTTP请求。 使用CHttpFile :: AddRequestHeaders和CHttpFile :: SendRequest。 查找文件。如果找不到该文件,则返回FALSE。 从文件读取。 使用CHttpFile。 使用您提供的缓冲区读取指定的字节数。 处理例外。 使用CInternetException类。 处理所有常见的Internet异常类型。 结束HTTP会话。 处理CInternetSession对象。 自动清理打开的文件句柄和连接。 也可以看看 概念 Win32 Internet Extensions(WinInet) Internet客户端类的先决条件 使用MFC WinInet类编写Internet客户端应用程序