在用WinInet, Post文件倒服务器上时候只要给的服务器的url不存在,比如 www.xxx.fuck就会产生例外,同时伴随内存泄漏, 我怎么也找不到哪里泄漏了代码如下:
---------------------------------------------
// Post data to server
// url indicates the relative path to the server, "/foo.asp"
BOOL CMyHttps::PostTextFile(CString &text, CString filename, CString strServiceName, CString url, CString &response)
{
int iLen = text.GetLength();
return PostFile(text.GetBuffer(), iLen, _T("text/plain"), filename, strServiceName,  url, response);
} BOOL CMyHttps::PostFile(TCHAR *pFileToUpload, int iFileLen, CString filetype,
CString filename, CString strServiceName, CString url, CString &response)
{
if(!m_pConnection)
return FALSE; try
{
DWORD dwFlags = GetInternetFlag(); CHttpFile *pFile = m_pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,
url, NULL, 1, NULL, NULL, dwFlags); CString strHTTPBoundary = _T("IllBeVerySurprisedIfThisTurnsUp");
CString strPreFileData = MakePreFileData(strHTTPBoundary, filename, strServiceName, filetype);
CString strPostFileData = MakePostFileData(strHTTPBoundary); DWORD dwTotalRequestLength = 
strPreFileData.GetLength() +
strPostFileData.GetLength() + iFileLen; if(pFile)
{
pFile->AddRequestHeaders(MakeRequestHeaders(strHTTPBoundary));
BOOL bRequestOK = pFile->SendRequestEx(dwTotalRequestLength, HSR_SYNC | HSR_INITIATE); if(!bRequestOK)
{
pFile->Close();
delete pFile;
return FALSE;
} USES_CONVERSION; #ifdef _UNICODE
  pFile->Write(W2A(strPreFileData), strPreFileData.GetLength());
 #else
  pFile->Write((LPTSTR)(LPCTSTR)strPreFileData, strPreFileData.GetLength());
 #endif
 
 
 #ifdef _UNICODE
  pFile->Write(W2A(pFileToUpload), iFileLen);
 #else
  pFile->Write((LPTSTR)(LPCTSTR)pFileToUpload, iFileLen);
 #endif
 
 
 #ifdef _UNICODE
  pFile->Write(W2A(strPostFileData), strPostFileData.GetLength());
 #else
  pFile->Write((LPTSTR)(LPCTSTR)strPostFileData, strPostFileData.GetLength());
 #endif
  pFile->EndRequest(HSR_SYNC);
// Status Code
pFile->QueryInfoStatusCode(m_dwStatusCode);
if(m_dwStatusCode != 200)
{
pFile->Close();
delete pFile;
return FALSE;
} // get the size of Content-Length
CString strContentLength;
pFile->QueryInfo(HTTP_QUERY_CONTENT_LENGTH, strContentLength);
int nContentLength = _ttoi(strContentLength); UINT nReadCount = 0; int HTTP_READ_BUFFER_SIZE = nContentLength > 0 ? nContentLength : 4096;
char * szBuf = new char[HTTP_READ_BUFFER_SIZE+1];
memset(szBuf, 0, HTTP_READ_BUFFER_SIZE+1); response.Empty(); while(true)
{
memset(szBuf,0,HTTP_READ_BUFFER_SIZE+1);
// nReadCount = pFile->Read(szBuf,HTTP_READ_BUFFER_SIZE);
nReadCount = pFile->Read(szBuf,
(pFile->GetLength() < HTTP_READ_BUFFER_SIZE) ? pFile->GetLength() : HTTP_READ_BUFFER_SIZE); if(nReadCount <= 0)
{
break;
} response += szBuf;
} response += szBuf;
delete []szBuf; pFile->Close();
delete pFile;
}
}
catch(CInternetException * e)
{
// e->ReportError();
                           //////// 内存泄漏
e->Delete();
return FALSE;
} return TRUE;
}