I'm new in programming and i wanted to make my app using C++ download data behind proxy,
i just detect if the user is behind proxy by request like this code:
int CWeatherInfoDlg::FindWebAddress(char *szAuthLine)
{
DWORD dwRet = 0;
BOOL bResult;
char szTemp[256];
struct in_addr inAddr;
CString sAddr;
DWORD dwIPNr;
TRACE("FindWebAddress()\n");
CInternetSession *pSession = new CInternetSession(_T("GetIPNr"), 1, INTERNET_OPEN_TYPE_PRECONFIG);
CHttpConnection* pConnection = pSession->GetHttpConnection(_T("checkip.dyndns.com"));
CHttpFile* pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_GET, _T("/"));
if(szAuthLine[0]) {
pFile->AddRequestHeaders(szAuthLine, HTTP_ADDREQ_FLAG_ADD, strlen(szAuthLine));
}
try
{
TRACE("Check Network Setting...\n");
bResult = pFile->SendRequest(NULL);
TRACE("SendRequest...\n");
}
catch (CInternetException* pEx)
{
pEx->Delete();
pFile->Close();
delete pFile;
pConnection->Close();
delete pConnection;
delete pSession;
return 0; }
pFile->QueryInfoStatusCode(dwRet);
if(dwRet / 100 == 2) {
char *p = new char[1024];
char *q = p;
TRACE1("FindWebAddress - Return code is: %i\n", dwRet);
pFile->Read(p, 1024); dwIPNr = 0;
while(*p) {
int n = strcspn(p, "1234567890");
p += n;
dwIPNr = GetValidIP(&p); if(dwIPNr)
{ memmove (&inAddr, &dwIPNr, 4);
sAddr = inet_ntoa (inAddr);
sprintf_s(szTemp, "Web address: \t%s\r\n", sAddr);
TRACE2(szTemp, "Web address: \t%s\r\n", sAddr);
szTotResult += szTemp;
}
}
delete q;
}
pFile->Close();
delete pFile;
pConnection->Close();
delete pConnection;
delete pSession;
return dwRet;
}
So the return code is 407 when i`m behind normal proxy server, but i have to request:
1. How to detect Proxies types?
2. How to check if the user input correct UserID and Password when Authentication is needed...
Any Sample or advice will appreciated (I'm new in C/C++)