Naughter Software Logo

WinHTTPWrappers v1.34 A set of C++ classes to encapsulate WinHTTP

Welcome to WinHTTPWrappers, a set of C++ classes to encapsulate WinHTTP and especially its asynchronous support. The classes are based on the MSDN Magazine article about WinHTTP by Kenny Kerr at 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: WinHTTPWrappers::CHandle, WinHTTPWrappers::CSession, WinHTTPWrappers::CConnection, WinHTTPWrappers::CRequest, WinHTTPWrappers::CResolver, WinHTTPWrappers::CWebSocket, WinHTTPWrappers::CAsyncDownloader & WinHTTPWrappers::CSyncDownloader.

CHandle 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.

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

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

CRequest 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.

CResolver provides encapsulation of a WinHTTP resolver HINTERNET handle as created via the WinHttpCreateProxyResolver API.

CWebSocket provides encapsulation of a WinHTTP web sockets HINTERNET handle as created via the WinHttpWebSocketCompleteUpgrade API.

CAsyncDownloader which derives from CRequest which provides for a high level wrapping of an asynchronous WinHTTP request. It supports sending request bodies from a file or from an in-memory array. It also supports downloading to a file or to an in-memory array. Internally this class looks after a memory buffer and file for downloading the request into. It also supports various authentication schemes and bandwidth throttling. It also implements proper thread protection of these values to ensure correct operation when WinHTTP is used in asynchronous mode. It also provides a number of virtual methods, including OnReadData, OnWriteData, GetHeaders, GetContentLength, DoAuthentication, ChooseAuthScheme, On407Response, On401Response and OnCallbackComplete which provide various notifications during the lifetime of a WinHTTP download request.

Finally CSyncDownloader which derives from CAsyncDownloader is provided. This class provides a high level wrapping of a synchronous WinHTTP request.





The enclosed zip file contains the WinHTTPWrappers source code and a simple VC 2017 dialog based application which demonstrates the classes using a simply asynchronous download of a HTTP page to a local file using the "CMyDownloadFileWinHTTPRequest" class. It also demonstrates cancelling of pending requests as well as reporting the various callbacks which occur during the download.





v1.34 (17 August 2022)

v1.33 (16 May 2022)

v1.32 (10 February 2022)

v1.31 (22 January 2022)

v1.30 (25 July 2021)

v1.29 (24 July 2021)

v1.28 (9 April 2021)

v1.27 (13 November 2020)

v1.26 (12 April 2020)

v1.25 (1 February 2020)

v1.24 (18 January 2020)

v1.23 (17 December 2019)

v1.22 (3 November 2019)

v1.21 (16 September 2019)

v1.20 (14 August 2019)

v1.19 (23 June 2019)

v1.18 (19 April 2019)

v1.17 (24 November 2018)

v1.16 (29 September 2018)

v1.15 (2 September 2018)

v1.14 (23 May 2018)

v1.13 (18 September 2017)

v1.12 (27 April 2017)

v1.11 (16 April 2017)

v1.10 (6 March 2016)

v1.09 (7 November 2015)

v1.08 (14 June 2015)

v1.07 (11 March 2015)

v1.06 (8 March 2015)

v1.05 (8 June 2014)

v1.04 (1 December 2013)

v1.03 (30 March 2013)

v1.02 (1 August 2011)

v1.01 (30 May 2011)

v1.0 (29 May 2011)