Jaw
2010-01-08 10:19:48 UTC
Hi, All
I am wondering what's missed in my code, but have no luck after
surveying around.
Here is my code, it should be very simple and straight, hopefully
somebody could give me a hand....
[code]
HINTERNET hInternet = InternetOpen(L"TEST",
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
// "localhost" is a local HTTP server, it needs to be unauthorized to
connect
// I fills the username/password here
HINTERNET hConnection = InternetConnect(hInternet, L"localhost", 80,
L"admin", L"1234", INTERNET_SERVICE_HTTP, 0, 0 );
// index.cgi is a simple HelloWorld cgi program written by C
HINTERNET hData = HttpOpenRequest( hConnection , L"GET", L"/cgi-bin/
index.cgi", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0 );
// HTTP server show me "unauthorized" with HTMLed pMyBuffer
HttpSendRequest( hData, NULL, 0, NULL, 0);
DWORD dwRead = 0;
InternetReadFile( hData, pMyBuffer, 255, &dwRead );
[/code]
Am I missing something? I set up WireShark to inspect the HTTP
packets, and detected that the request packet doesn't carry with
authorization. Am I need to provide authentication by another way?
Any idea is appreciated, Jaw
I am wondering what's missed in my code, but have no luck after
surveying around.
Here is my code, it should be very simple and straight, hopefully
somebody could give me a hand....
[code]
HINTERNET hInternet = InternetOpen(L"TEST",
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
// "localhost" is a local HTTP server, it needs to be unauthorized to
connect
// I fills the username/password here
HINTERNET hConnection = InternetConnect(hInternet, L"localhost", 80,
L"admin", L"1234", INTERNET_SERVICE_HTTP, 0, 0 );
// index.cgi is a simple HelloWorld cgi program written by C
HINTERNET hData = HttpOpenRequest( hConnection , L"GET", L"/cgi-bin/
index.cgi", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0 );
// HTTP server show me "unauthorized" with HTMLed pMyBuffer
HttpSendRequest( hData, NULL, 0, NULL, 0);
DWORD dwRead = 0;
InternetReadFile( hData, pMyBuffer, 255, &dwRead );
[/code]
Am I missing something? I set up WireShark to inspect the HTTP
packets, and detected that the request packet doesn't carry with
authorization. Am I need to provide authentication by another way?
Any idea is appreciated, Jaw