Hi I've adapted a CodeProject sample (here: http://www.codeproject.com/internet/urldownload.asp) illustating the use of URLDownloadToFile which is working very nicely indeed. One problem I've come across is that I need to somehow retrieve both the HTTP response code and parse the response headers to get the MIME type of the file I've just downloaded. After trawling through MSDN I discovered the IHttpNegotiate interface. I thought it would be as simple as extending my CBindStatusCallbackImpl class (which currently derives from and implements IBindStatusCallback) to derive from IHttpNegotiate also, and to override the OnResponse method. But alas, when I debug the application my OnResponse callback never seems to be hit. I'm just wondering if this is the correct way of getting the response code and headers? Or will I have to write a full implementation of IBindStatusCallback myself to store the file, rather than using the elegant URLDownloadToFile? Any help would be greatly appreciated. Cheers, Dave.
wrote in message news:1193827251.330264.207580@50g2000hsm.googlegroups.com > I've adapted a CodeProject sample (here: > http://www.codeproject.com/internet/urldownload.asp) illustating the > use of URLDownloadToFile which is working very nicely > indeed. > > One problem I've come across is that I need to somehow retrieve both > the HTTP response code and parse the response headers to get the MIME > type of the file I've just downloaded. > > After trawling through MSDN I discovered the IHttpNegotiate interface. > > I thought it would be as simple as extending my > CBindStatusCallbackImpl class (which currently derives from and > implements IBindStatusCallback) to derive from IHttpNegotiate also, > and to override the OnResponse method. But alas, when I debug the > application my OnResponse callback never seems to be hit. Did you also update your QueryInterface implementation to report this interface when queried for? -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
Hi Igor, My QueryInterface method currently returns E_NOTIMPL. If you have a look at Michael Dunn's sample this is what he has implemented. According to the comment in his code (see BindStatusCallback.h) he states that IE never calls any of these methods. I never thought of putting a breakpoint on my QueryInterface after reading the comment. I can definitely put this in alright. But does this mean that I'd have to implement AddRef and Release also? I'm also curious how my IBindStatusCallback::OnProgress method gets called back without QueryInterface being implemented. Could you possibly give me an explanation? After seeing the Win32 POSTMON sample (which has a full implementation of IBindStatusCallback and IHttpNegotiate) and seeing how I can do exactly the same thing with URLDownloadToFile, I'd prefer to keep things as simple as possible. Thanks again. Dave.
wrote in message news:1193833699.304578.177050@o3g2000hsb.googlegroups.com > My QueryInterface method currently returns E_NOTIMPL. If you have a > look at Michael Dunn's sample this is what he has implemented. Well, his implementation is wrong, but he managed to get away with it because he supports just one interface. You are not so lucky, so you would have to implement QueryInterface properly. > According to the comment in his code (see BindStatusCallback.h) he > states that IE never calls any of these methods. You'll be surprised. > I never thought of putting a breakpoint on my QueryInterface after > reading the comment. I can definitely put this in alright. > But does this mean that I'd have to implement AddRef and Release also? Not necessarily. You may have other means of controlling the lifetime of your object than reference count. > I'm also curious how my IBindStatusCallback::OnProgress method gets > called back without QueryInterface being implemented. You pass IBindStatusCallback pointer to the function initially, so it doesn't need QueryInterface to get to it. But it does need it to get to any other interface you might have implemented on the same object. -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
Hi Igor, Just to let you know that you were right on the money! A simple implementation of QueryInterface, along with BeginTransaction and OnResponse and I am now getting my response headers and HTTP response code. Thanks again. You are the man!!! Cheers, Dave.