Return TypeFunction nameArguments
hzEcodehzHttpClient::PostAjax(HttpRC&,const hzUrl&,hzVect<hzString>&,const hzList<hzPair>&,)

Declared in file: hzHttpClient.h
Defined in file : hzHttpClient.cpp

Function Logic:

0:START 1:hzChain::Clear hzChain::Clear hzChain::Clear hzList::Count 2:!formData.Count() 3:Return E_NODATA 4:iD.Valid(); 5:hzList::Iter::Element P hzChain::Size 6:F.Size() 7:hzChain::AddByte 8:items hzChain::AddByte items 9:hzUrl::Domain dom hzUrl::Resource res hzUrl::Port nPort hzUrl::IsSSL 10:url.IsSSL() 11:hzChain::Printf 12:hzChain::Printf 13:items items nIndex 14:nIndex 15:hzMapS::GetObj cookie 16:cookie.m_Flags&COOKIE_HTTPONLY 17:hzChain::Printf 18:items hzChain::Size hzChain::Printf items hzVect::Count 19:hdrs.Count() 20:nIndex 21:items 22:items items S hzUrl::IsSSL 23:url.IsSSL() 24:hzTcpClient::ConnectSSL rc 25:hzTcpClient::ConnectStd rc 26:rc!=E_OK 27:Return rc 28:hzTcpClient::Send rc 29:Return rc

Function body:

hzEcode hzHttpClient::PostAjax (HttpRC& hRet, const hzUrl& url, hzVect<hzString>& hdrs, const hzList<hzPair>& formData)
{
   _hzfunc("hzHttpClient::PostAjax") ;
   hzList<hzPair>::Iter    iD ;
   hzChain     F ;
   hzCookie    cookie ;
   hzPair      P ;
   hzString    dom ;
   hzString    res ;
   hzString    S ;
   uint32_t    nPort ;
   uint32_t    nIndex ;
   hzEcode     rc ;
   m_Header.Clear() ;
   m_Content.Clear() ;
   m_Request.Clear() ;
   if (!formData.Count())
       return E_NODATA ;
   for (iD = formData ; iD.Valid() ; iD++)
   {
       P = iD.Element() ;
       if (F.Size())
           F.AddByte(CHAR_AMPSAND) ;
       F << P.name ;
       F.AddByte(CHAR_EQUAL) ;
       F << P.value ;
   }
   dom = url.Domain() ;
   res = url.Resource() ;
   nPort = url.Port() ;
   if (url.IsSSL())
       m_Request.Printf("POST https://%s%s HTTP/1.1\r\n", *dom, *res) ;
   else
       m_Request.Printf("POST http://%s%s HTTP/1.1\r\n", *dom, *res) ;
   m_Request << "Accept: text/*\r\n" ;
   m_Request << "Accept-Language: en-gb\r\n" ;
   for (nIndex = 0; nIndex < m_Cookies.Count() ; nIndex++)
   {
       cookie = m_Cookies.GetObj(nIndex) ;
       if (cookie.m_Flags & COOKIE_HTTPONLY)
           continue ;
       m_Request.Printf("Cookie: %s=%s\r\n", *cookie.m_Name, *cookie.m_Value) ;
   }
   m_Request << "User-Agent: HadronZoo/0.8 Linux 2.6.18\r\n" ;
   m_Request.Printf("Content-Length: %d\r\n", F.Size()) ;
   m_Request << "Host: " << dom << "\r\n" ;
   if (hdrs.Count())
   {
       for (nIndex = 0; nIndex < hdrs.Count() ; nIndex++)
           m_Request << hdrs[nIndex] ;
   }
   m_Request << "Connection: close\r\n\r\n" ;
   m_Request << F ;
   S = m_Request ;
   threadLog("Sending [\n%s]\n", *S) ;
   if (url.IsSSL())
       rc = m_Webhost.ConnectSSL(dom, nPort) ;
   else
       rc = m_Webhost.ConnectStd(dom, nPort) ;
   if (rc != E_OK)
       return rc ;
   rc = m_Webhost.Send(m_Request) ;
   return rc ;
}