MFC库参考 典型HTTP客户端应用程序中的步骤

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客户端应用程序
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值