Return Type | Function name | Arguments |
---|---|---|
hzEcode | hzHttpClient::PostForm | (HttpRC&,const hzUrl&,hzVect<hzString>&,const hzList<hzPair>&,) |
Declared in file: hzHttpClient.h
Defined in file : hzHttpClient.cpp
Function Logic:
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 ; }