void CIVConnection::OnPostRequest (WPARAM wParam, LPARAM lParam) { ASSERT (!m_strRequest.IsEmpty()); try { InitSession(); CString strSID = Login(); CString strRequest; strRequest.Format (m_strRequest, (LPCTSTR) strSID ); GetHTTPData (strRequest, m_strResult); } catch (CException * e ) { e->Delete(); } CloseSession(); SetReady (true); }
CString CIVConnection::Login() { CString strQuery; CString strURL; if(-1 == m_opts.m_strURL.Find(_T("http"))) { strURL = _T("http://"); strURL += m_opts.m_strURL; } else strURL = m_opts.m_strURL; strQuery.Format (_T("%s/auth.asp?name=%s"), (LPCTSTR) strURL, (LPCTSTR) m_opts.m_strAccount); CString strResult; if(!m_opts.m_strAccount.GetLength()) { CString strError; AfxFormatString1 (strError, ERR_IDS_IV_CANNOT_LOGIN, _T("")); SetError (strError); AfxThrowUserException(); } GetHTTPData(strQuery, strResult); if (strResult.IsEmpty() || strResult.GetLength()<6 || *(LPCSTR)strResult < '0' || *(LPCSTR)strResult >'9') { CString strError; AfxFormatString1 (strError, ERR_IDS_IV_CANNOT_LOGIN, m_opts.m_strAccount); SetError (strError); AfxThrowUserException(); } if (m_spIMD5 == NULL) { HRESULT hr = m_spIMD5.CreateInstance (__uuidof(IC::MD5)); if (FAILED (hr)) { SetError (ERR_IDS_IV_MD5); AfxThrowUserException(); } } CString strSID; try { CString strInput = strResult; strInput += m_opts.m_strPassword; BSTR bstrInput = strInput.AllocSysString(); _bstr_t bstrTemp (bstrInput, false); strSID = (BSTR) m_spIMD5->GetMDString (&bstrInput); } catch (_com_error & ) { CString strErr ( (LPCSTR) ERR_IDS_UNEXPECTED ) ; AfxThrowUserException(); } return strSID; }
int GetData(const char * url, unsigned short **body, string referer) { return GetHTTPData(url, body, referer); }
int PostData(const char * url, unsigned short **body, string referer, string post_info) { return GetHTTPData(url, body, referer, true, post_info); }
int TrackerConnection::GetData(const char * url, unsigned short **body, string referer) { return GetHTTPData(url, body, referer, false, ""); }