int CHttpFetch::Post(const CString& strURL, const CString& strContent, CString& strResponse)
{
int nStatus = 200;
try
{
http::client::request request(StringUtility::CStr2Stl(strURL));
std::string content = StringUtility::CStr2Stl(strContent);
CString strContentLength;
strContentLength.Format(_T("%d"), content.length());
request << header("Content-Length", StringUtility::CStr2Stl(strContentLength));
request << header("Content-Type", "application/x-www-form-urlencoded");
request << body(content);
http::client::response response = m_client.post(request);
strResponse = StringUtility::Stl2CStr(chunked_body(response));
nStatus = status(response);
}
catch (std::exception& e)
{
UNREFERENCED_PARAMETER(e);
nStatus = 500;
}
return nStatus;
}