Steps in a Typical HTTP Client Application
The following table shows the steps you might perform in a typical HTTP client application:
(下面的图表会告诉你实现一般HTTP请求的几个步骤)
Your goal(目的) | Actions you take(你需要做的) | Effects(作用) |
---|---|---|
Begin an HTTP session. (开始一个HTTP对话) | Create a CInternetSession object. (创建一个CInternetSession)类的对象 | Initializes WinInet and connects to server. 初始化Winlent 然后连接上服务 |
Connect to an HTTP server. (连接到一个HTTP服务) | Use CInternetSession::GetHttpConnection. 用此类的此方法 | Returns a CHttpConnection object. 返回一个此类型的对象 |
Open an HTTP request 打开一个HTTO请求. | Use CHttpConnection::OpenRequest. 用此类的此方法 | Returns a CHttpFile object 返回一个此类型的对象. |
Send an HTTP request. 发送一个HTTP请求 | Use CHttpFile::AddRequestHeaders andCHttpFile::SendRequest. 用此类的此方法 | Finds the file. Returns FALSE if the file is not found 寻找服务器返回的文件,如果返回值为FALSE则没有. |
Read from the file. 读取返回文件 | Use CHttpFile. 用此类 | Reads the specified number of bytes using a buffer you supply. 用一个你的buffer去读按特殊字节去读取 |
Handle exceptions. 报错处理 | Use the CInternetException class. 用此类 | Handles all common Internet exception types. 处理所有常用互联网错误类型 |
End the HTTP session. 结束HTTP对话 | Dispose of the CInternetSession object. 处理刚刚创建的此类对象 | Automatically cleans up open file handles and connections. 自动清理 |