I'm having a problem with this simple code... :mad:

It's supposed to connect to a webserver set up in at port 80 and fetch the index page. But the call to HttpSendRequest is failing with an error code of 0x2efd (ERROR_INTERNET_CANNOT_CONNECT). No network activity takes place (checked that with WinDump) and I can connect manually to the webserver using telnet. So I figure the only possible problem would be bad parameters to one of the API calls. Since until HttpSendRequest is called no action is really taken, the error could be in any of the other calls.

Also I had problems running it under a debugger. OlylDbg just chokes on the call to HttpSendRequest (I posted that here) and WinDbg signals so many memory access violations within wininet.dll that I had to disable that event to get past the api call.

Could anyone lend a hand please? I'm totally stuck with this one. :sad:

Thanks in advance. :)
Posted on 2005-09-30 11:25:06 by QvasiModo
May be the reason is that you are passing a string port value  to InternetConnect.
Replace cstr("80") with  80 (INTERNET_DEFAULT_HTTP_PORT)

I have to go now. Hope this helps.



Posted on 2005-09-30 11:37:39 by Kecol
OMG, I can't believe I got stuck with it for two hours! :O

Thanks a ton! :D

Posted on 2005-09-30 11:44:40 by QvasiModo
I just found another problem. The "Accept" header is always empty. First I thought the problem was I was passing a single string rather than an array of strings as the lpszAcceptTypes parameter in HttpOpenRequest. But after fixing that the problem is still there... no matter what I use for that parameter I'm always getting the same request headers.
Posted on 2005-09-30 17:14:02 by QvasiModo
Mhm... I think I got it.

LPCTSTR* lpszAcceptTypes

That would be a pointer to an array of pointers to strings, with the last pointer being NULL. How tricky.
Posted on 2005-09-30 17:52:05 by QvasiModo