Return TypeFunction nameArguments
hzEcodehzHttpClient::PostForm(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::Printf 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 hzString::UrlEncode items 9:dest hzHttpClient::_postform rc 10:rc!=E_OK 11:Err2Txt hzChain::Printf 12:Return rc 13:hRet==HTTPMSG_REDIRECT_PERM||hRet==HTTPMSG_REDIRECT_TEMP; 14:!m_Redirect 15:hzChain::Printf 16:m_Redirect[0]==(char)47 17:hzUrl::Domain dom hzUrl::SetValue 18:dest 19:hzChain::Printf etag hzHttpClient::_getpage rc 20:rc!=E_OK 21:Err2Txt hzChain::Printf 22:Return rc

Function body:

hzEcode hzHttpClient::PostForm (HttpRC& hRet, const hzUrl& url, hzVect<hzString>& hdrs, const hzList<hzPair>& formData)
{
   _hzfunc("hzHttpClient::PostForm") ;
   hzList<hzPair>::Iter    iD ;
   hzChain     F ;
   hzCookie    cookie ;
   hzPair      P ;
   hzUrl       dest ;
   hzString    dom ;
   hzString    res ;
   hzString    etag ;
   hzEcode     rc ;
   m_Error.Clear() ;
   m_Error.Printf("POSTING FORM %s\n", *url) ;
   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) ;
       P.value.UrlEncode() ;
       F << P.value ;
   }
   dest = url ;
   rc = _postform(hRet, dest, hdrs, F) ;
   if (rc != E_OK)
   {
       m_Error.Printf("FAILED (error=%s)\n", Err2Txt(rc)) ;
       return rc ;
   }
   for (; hRet == HTTPMSG_REDIRECT_PERM || hRet == HTTPMSG_REDIRECT_TEMP ;)
   {
       if (!m_Redirect)
           m_Error.Printf("Oops - no URL to redirect to\n") ;
       else
       {
           if (m_Redirect[0]== CHAR_FWSLASH)
               { dom = dest.Domain() ; dest.SetValue(dom, m_Redirect) ; }
           else
               dest = m_Redirect ;
           m_Error.Printf("redirecting to %s\n", *dest) ;
           etag = (char*) 0;
           rc = _getpage(hRet, dest, etag) ;
           if (rc != E_OK)
           {
               m_Error.Printf("Redirect FAILED (error=%s)\n", Err2Txt(rc)) ;
               break ;
           }
       }
   }
   return rc ;
}