Defined in file: hzHttpClient.h

The hzHttpClient class enables programs to operate as HTTP clients (e.g. webbots). It consists of a hzTcpClient, a set of cookies and a set of values derived from browsing the target HTTP service (website). The class provides functions to GET resources (pages) and POST forms. Nothing is known or assumed about the pages being requested or the forms being posted.

Constructors/Detructors

hzHttpClient*hzHttpClient(void)
void~hzHttpClient(void)

Public Methods:

hzEcodeClose(void)
hzEcodeConnect(hzUrl& url)
hzEcodeGetPage(HttpRC& hRet)hzUrl& url, hzString& etag, Get a HTTP page from a website. Note that the whole page is retrieved or abandoned before this function returns. Some servers send pages with the header 'Transfer-Encoding: chunked' instead of the 'Content-Length:' header. This is done because the size of the page is not known at the start of transmission. The body part of the message is sent in chunks with the chunk size given (in hex on a line by itself) at the start of each chunk. Because of the existance of the chunked approach, this function has to handle it but it is currently not possible for applications to take advantage in the intended way. Instead applications calling this function have to wait until it returns with a complete page, however long! Note that no assumptions can be made about packets that are sent except that since the connection is TCP, they will be in order. The header may be comprised of a number of whole packets or it may be that a packet stradles the end of the header and the start of the contents.
hzEcodePostAjax(HttpRC& hRet)hzUrl& url, hzVect<hzString>& hdrs, hzList<hzPair>& formData, Post a form to the server but do not seek a HTTP response.
hzEcodePostForm(HttpRC& hRet)hzUrl& url, hzVect<hzString>& hdrs, hzList<hzPair>& formData, Post a form to the server. Note that this will normally result in a HTTP response. This response must be processed in the same way (ie values are extracted from lines in the HTTP header).
hzEcodeTestPage(hzChain& Z)hzUrl& url, Get a HTTP page from a website but do not process it in any way. This is for speed testing only. Note: The website (server) must already be connected to. No account is taken of redirected pages.
hzEcodeUpgradeWS(HttpRC& hRet)hzUrl& url,
hzEcode_getpage(HttpRC& hRet)hzUrl& url, hzString& etag, Get a HTTP page from a website but do not redirect. This is a support function for GetPage()
hzEcode_postform(HttpRC& hRet)hzUrl& url, hzVect<hzString>& hdrs, hzChain& formData, Support function for hzHttpClient::PostForm(). Compiles the HTTP request and adds the supplied form. The functionality herin would just appear in PostForm() except for the need to cope with redirection. This requires that the request ...
hzEcode_procHttpResponse(HttpRC& hRet)hzUrl& url, Support funtion to the hzHttpClient member functions GetPage() and PostForm(). The purpose is to gather the server response to an earlier HTTP GET, POST or HEAD request.

Member Variables:

hzXDatem_AccessedDate of last access (downloaded). Derived from 'Date:' field in header.
hzStringm_AltProtoThe only expected value here is 'chunked'
hzStringm_AuthBasicIf set, this is supplied with each GetPage() call.
hzStringm_CacheCtrlCache control
hzStringm_ContEncodingEg 'gzip'
hzChainm_ContentHTML page content of server's response
hzStringm_ContentTypeContent type
hzMapS<hzString,hzCookie>m_CookiesCookies applicable to the target website
hzStringm_EncodingContent encoding eg UTF-8
hzChainm_ErrorError logging
hzStringm_EtagEntity tag if present in the header
hzXDatem_ExpiresDate page expires (after which it must be re-loaded)
hzChainm_HeaderHeader of server's response
hzStringm_HostDomain name or host currently connected to
hzStringm_KeepAliveKeep-Alive parameters (currently ignored)
hzXDatem_ModifiedDate of last modification (from header). Default will be date/time of download.
hzStringm_PragmaPragma directive
hzStringm_RedirectWhere to go to actually load the page
hzUrlm_RefererLast page (used in constructing 'Referer:' header)
hzChainm_RequestChain formed by GetHttpPage() to send a request to a server
uint32_tm_RetcodeHTML return code
hzTcpClientm_WebhostCurrent connection
hzStringm_XferEncodingThe only expected value here is 'chunked'
boolm_bChunkedServer's response was chunked (diagnostics only)
boolm_bConnectionTrue if server returns Keep-Alive
char*m_bufBuffer for IP packets
uint32_tm_nContentLenContent length
uint32_tm_nMaxConnectsMaximum connections (we only ever use one)
uint32_tm_nTimeoutMaximum timeout
uint64_tm_rtRequestRequest sent time
uint64_tm_rtResponseResponse complete time