5 out of 6 rated this helpful - Rate this topic
Microsoft Windows HTTP Services (WinHTTP) is targeted at middle-tier and back-end server applications that require access to an HTTP client stack. Microsoft Windows Internet (WinINet) provides an HTTP client stack for client applications, as well as access to the File Transfer Protocol (FTP), SOCKSv4, and Gopher protocols. This overview can help determine whether porting your WinINet applications to WinHTTP would be beneficial. It also describes specific conversion requirements.
Things to Consider Before Porting Your WinINet Application Consider porting your WinINet application to WinHTTP if your application would benefit from:
A server-safe HTTP client stack. Minimized stack usage. The scalability of a server application. Fewer dependencies on platform-related APIs. Support for thread impersonation. A service-friendly HTTP stack. Access to the scriptable WinHttpRequest object.
Do not consider porting your WinINet application to WinHTTP if it must support one or more of the following:
The FTP or Gopher protocol from the HTTP stack. Support for SOCKSv4 protocol for communicating with SOCKS proxies. Automatic dial-up services.
If you decide to port your application to WinHTTP, the following sections guide you through the conversion process.
For a sample application for both WinINet and WinHTTP, compare the AsyncDemo sample for WinINet with the AsyncDemo sample for WinHTTP.
WinHTTP Equivalents to WinINet Functions The following table lists WinINet functions related to the HTTP client stack together with the WinHTTP equivalents.
If your application requires WinINet functions that are not listed, do not port your application to WinHTTP.
WinINet function WinHTTP equivalent Notable changes HttpAddRequestHeaders WinHttpAddRequestHeaders None. HttpEndRequest WinHttpReceiveResponse The context value is set with WinHttpSendRequest or WinHttpSetOption . Request options are set withWinHttpOpenRequest . WinHttpReceiveResponse must be called after sending a request. HttpOpenRequest WinHttpOpenRequest The context value is set with WinHttpSendRequest or WinHttpSetOption . HttpQueryInfo WinHttpQueryHeaders None. HttpSendRequest WinHttpSendRequest The context value can be set withWinHttpSendRequest . HttpSendRequestEx WinHttpSendRequest Buffers cannot be provided. InternetCanonicalizeUrl No equivalent URLs are now put in canonical form inWinHttpOpenRequest . InternetCheckConnection No equivalent Not implemented in WinHTTP. InternetCloseHandle WinHttpCloseHandle Closing a parent handle in WinHTTP does not recursively close child handles. InternetCombineUrl No equivalent URLs can be assembled with the WinHttpCreateUrl function. InternetConfirmZoneCrossing No equivalent Not implemented in WinHTTP. InternetConnect WinHttpConnect The context value is set with WinHttpSendRequest or WinHttpSetOption . Request options are set withWinHttpOpenRequest . User credentials are set withWinHttpSetCredentials . InternetCrackUrl WinHttpCrackUrl Opposite behavior of the ICU_ESCAPE flag: withInternetCrackUrl , this flag causes escape sequences (%xx) to be converted to characters, but withWinHttpCrackUrl , it causes characters that must be escaped from in an HTTP request to be converted to escape sequences. InternetCreateUrl WinHttpCreateUrl None. InternetErrorDlg No equivalent Because WinHTTP is targeted at server-side applications, it does not implement any user interface. InternetGetCookie No equivalent WinHTTP does not persist data between sessions and cannot access WinINet cookies. InternetOpen WinHttpOpen None. InternetOpenUrl WinHttpConnect ,WinHttpOpenRequest ,WinHttpSendRequest ,WinHttpReceiveResponse This functionality is available in the WinHTTP functions listed. InternetQueryDataAvailable WinHttpQueryDataAvailable No reserved parameters. InternetQueryOption WinHttpQueryOption WinHTTP offers a different set of options from WinINet. For more information and options offered by WinHTTP, see Option Flags . InternetReadFile WinHttpReadData None. InternetReadFileEx WinHttpReadData Rather than a structure, the buffer is a region of memory addressed with a pointer. InternetSetOption WinHttpSetOption None. InternetSetStatusCallback WinHttpSetStatusCallback For more information, see "Different Handling of Asynchronous Requests" in this topic. InternetTimeFromSystemTime WinHttpTimeFromSystemTime None. InternetTimeToSystemTime WinHttpTimeToSystemTime None. InternetWriteFile WinHttpWriteData None.
转自 msdn 有删节