Posts

Showing posts from February, 2014

Neat way of doing async HTTP request using WinApi

Recently, I needed to implement rather big part of the software based on HTTP requests with C++ and WinAPI. As soon as the old-school blocking APIs are not the way to go in the 2014, I was choosing between COM-based WinHTTP and WinInet. I chose the latest because I read this  (there is a lot more "yes" there on the WinInet side;)) and I software was not a service. So here we go. C-style asynchronous API and OOP. Need to make a wrap, and good one - I will use it later almost everywhere! But how could I do it the best way in the world (I am currently aware of, of course;))? I decided to use the next schema: 1) Any class that needs to make an HTTP request, derives from "AsyncHttpRequest::Host" class 2) "AsyncHttpRequest::Host" class has the special static method making requests and special virtual method used as a callback 3) "AsyncHttpRequest::Host" also should take care of the request creating and destroying, i.e. memory management - to mak