Home > Web Site Updates > WinHttpWrappers v1.0

WinHttpWrappers v1.0

May 29, 2011

Just to let everyone know that v1.0 of WinHttpWrappers, a set of MFC classes to encapsulate WinHttp and especially its asynchronous support. The classes are based on the MSDN Magazine article about WinHttp by Kenny Kerr at http://msdn.microsoft.com/en-gb/magazine/cc716528.aspx. You should read this article to get a better understanding on how to properly use WinHttp (especially when in asynchronous mode). Coming back to my classes then should make more sense<gg>.


The classes provided are: CWinHttpHandle, CWinHttpSession, CWinHttpConnection, CWinHttpRequest & CDownloadFileWinHttpRequest.

CWinHttpHandle provides a class based encapsulation of a HINTERNET handle and various WinHttp methods which work on any HINTERNET type handle. It also provides a prebuilt virtual callback method called "OnCallback" which derived classes can customize.

CWinHttpSession provides encapsulation of a WinHttp session HINTERNET handle. It provides an "Initialize" method which encapsulates the WinHttpOpen API.

CWinHttpConnection provides encapsulation of a WinHttp connection HINTERNET handle. It provides an "Initialize" method which encapsulates the WinHttpConnect API.

CWinHttpRequest provides encapsulation of a WinHttp request HINTERNET handle. It provides an "Initialize" method which encapsulates the WinHttpOpenRequest API. It also encapsulates all the WinHttp API calls which take a request handle such as WinHttpAddRequestHeaders, WinHttpQueryHeaders, WinHttpReadData, WinHttpQueryAuthSchemes etc etc.

The last class is CDownloadFileWinHttpRequest which derives from CWinHttpRequest which provides for asynchronous downloading of a URL to a local file. Internally this class looks after a memory buffer and file for downloading the request into. It also implements proper thread protection of these values to ensure correct operation when WinHttp is used in asynchronous mode. It also provides three virtual methods, namely OnReadData, OnWriteData and OnCallbackComplete to provide various notifications during the lifetime of a WinHttp download request.

Categories: Web Site Updates
%d bloggers like this: