使用MFC智能设备应用程序中的操作参数发送CHttpConnection :: HTTP_VERB_POST请求

时间:2013-07-16 11:57:37

标签: http visual-c++ post mfc smart-device

如何使用CHttpFile发送动作字符串参数? 这是我的代码

CInternetSession session(_T("My Session"));
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
try
{
CString strServerName = _T("192.168.1.39");

CString szHeaders = _T("Content-Type: text/plain");
//To Be Send    
**CString strFormData   _T("action=setCameraSetting&videoOverlay.useTimestamp=1&videoOverlay.useText=1&videoOverlay.displayString=12.12-77.32");**

INTERNET_PORT nPort = 1039;
DWORD dwRet;
CString strObject = _T("/cgi-bin/camera.cgi");
pServer = session.GetHttpConnection(strServerName, nPort, _T(""), _T(""));
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST, strObject);
pFile->AddRequestHeaders(szHeaders);
pFile->SendRequest();
pFile->QueryInfoStatusCode(dwRet);
delete pFile;
delete pServer;
}
catch (CInternetException* pEx)
{}
session.Close();

我为此获得了响应代码200 ..

0 个答案:

没有答案