URLDownloadToFile is making me mad
-
Hi there. Here's a pretty simple program: void main(void) { HRESULT hr = URLDownloadToFile(NULL, "http://www.google.com", "c:\\output.htm", 0, NULL) ; if (SUCCEEDED(hr)) { printf("success\n") ; } else { printf("failed\n") ; } } For some reason the URLDownloadToFile call fails. If I put any of a host of other urls in the call the download works perfectly, however, for www.google.com and several other pages (www.yahoo.es for one) the function just refuses to work. I'm completely baffled by this. I can't find any commonality between the pages that fail and I know that www.google.com does indeed exist on the internet. Has anyone else had problems using the URLDownloadToFile function? Thanks
-
Hi there. Here's a pretty simple program: void main(void) { HRESULT hr = URLDownloadToFile(NULL, "http://www.google.com", "c:\\output.htm", 0, NULL) ; if (SUCCEEDED(hr)) { printf("success\n") ; } else { printf("failed\n") ; } } For some reason the URLDownloadToFile call fails. If I put any of a host of other urls in the call the download works perfectly, however, for www.google.com and several other pages (www.yahoo.es for one) the function just refuses to work. I'm completely baffled by this. I can't find any commonality between the pages that fail and I know that www.google.com does indeed exist on the internet. Has anyone else had problems using the URLDownloadToFile function? Thanks
It would help to know the error returned by
URLDownloadToFile()
. One possibility is that the server doesn't allow downloads without a properHTTP_REFERER
header, which is not present when using that API. --Mike-- THERE IS NO THERE IS NO BUT THERE IS MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT Homepage | RightClick-Encrypt | 1ClickPicGrabber "You have Erica on the brain" - Jon Sagara to me -
It would help to know the error returned by
URLDownloadToFile()
. One possibility is that the server doesn't allow downloads without a properHTTP_REFERER
header, which is not present when using that API. --Mike-- THERE IS NO THERE IS NO BUT THERE IS MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT Homepage | RightClick-Encrypt | 1ClickPicGrabber "You have Erica on the brain" - Jon Sagara to me -
I experimented with this method and got the same problem for google and a few other sites. The error code is 0x800401e4 which translates to "Invalid syntax"???? Art
That's right, 0x800401e4 is MK_E_SYNTAX. MSDN describes this error for a different URL Moniker function (they don't even list it as a return value for URLDownloadToFile) and it says: A moniker could not be created because szURL does not correspond to valid URL syntax for a full or partial URL. This is uncommon, because most parsing of the URL occurs during binding and because the syntax for URLs is extremely flexible. So what's going on? I can't believe that I just can't use URLDownloadToFile at all in my application because it just doesn't download certain pages... Also I don't think the problem has to do with a bad header to www.google.com because I can get a response from the google server via telnet by just sending a request line and a "Host" header... They don't seem strangely picky about requiring headers.
-
That's right, 0x800401e4 is MK_E_SYNTAX. MSDN describes this error for a different URL Moniker function (they don't even list it as a return value for URLDownloadToFile) and it says: A moniker could not be created because szURL does not correspond to valid URL syntax for a full or partial URL. This is uncommon, because most parsing of the URL occurs during binding and because the syntax for URLs is extremely flexible. So what's going on? I can't believe that I just can't use URLDownloadToFile at all in my application because it just doesn't download certain pages... Also I don't think the problem has to do with a bad header to www.google.com because I can get a response from the google server via telnet by just sending a request line and a "Host" header... They don't seem strangely picky about requiring headers.