누구든지이 기능에서 문제를 찾을 수 있습니까? 내 응용 프로그램에서 여러 요청을하고 첫 요청이 SSL을 사용하는 경우 응용 프로그램이 일부 컴퓨터에서 충돌합니다 (광산 4 컴퓨터 + VM웨어에서는 충돌없이 정상적으로 작동 함). 여기wininet에 문제가 있습니다.
코드
char Buffer[1024];
DWORD dwRead;
string data;
string Request(string method, string host, string file, string headers,
string post, bool debug, bool SSL)
{
HINTERNET hSession, hDownload, hRequest;
DWORD flag;
DWORD port;
data.empty();
//SSL or not + flag :)
if (SSL)
{
port = INTERNET_DEFAULT_HTTPS_PORT;
flag = INTERNET_FLAG_SECURE; // FLAG_SECURE
}
else
{
port = INTERNET_DEFAULT_HTTP_PORT;
flag = INTERNET_FLAG_RELOAD; //FLAG_RELOAD
}
char * postdata;
postdata = new char[post.size() + 1];
strcpy(postdata, post.c_str());
char * headersdata;
headersdata = new char[headers.size() + 1];
strcpy(headersdata, headers.c_str());
//Actual request
hSession
= InternetOpen(
"Mozilla/5.0 (Windows; U; Windows NT 6.1; sl; rv:1.9.2.11) Gecko/20101012 Firefox/3.6.11",
INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (hSession)
{
hDownload = InternetConnect(hSession, host.c_str(), port, NULL, NULL,
INTERNET_SERVICE_HTTP, 0, 0);
if (hDownload)
{
hRequest = HttpOpenRequest(hDownload, method.c_str(), file.c_str(),
"HTTP/1.1", NULL, NULL, flag, 0);
if (hRequest)
{
if (strlen(headersdata) && strlen(postdata))
{
HttpSendRequest(hRequest, headersdata, strlen(headersdata),
postdata, strlen(postdata));
}
else
{
HttpSendRequest(hRequest, NULL, 0, NULL, 0);
}
}
}
}
//Writing HTML response in data buffer
while (InternetReadFile(hRequest, Buffer, sizeof(Buffer), &dwRead))
{
if (dwRead == 0)
{
break;
}
Buffer[dwRead] = 0;
data += Buffer;
}
//Debug :)
if (debug)
{
ofstream dbgfile;
dbgfile.open("debug.html");
dbgfile << data;
dbgfile.close();
}
//Close handles
InternetCloseHandle(hSession);
InternetCloseHandle(hDownload);
InternetCloseHandle(hRequest);
return data;
}
감사합니다.
충돌이 발생할 때 어떤 오류가 발생합니까? 액세스 위반? 다른 오류 코드가 있습니까? –
오류 **이 응용 프로그램은 비정상적인 방식으로 종료하도록 런타임을 요청했습니다 ** ** 너무 나쁘면 디버깅 할 수 없습니다. ( – pwnu91
원격 디버깅을 시도 할 수 있습니다 ... – smerlin