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:
| hzEcode | Close | (void) | |
| hzEcode | Connect | (hzUrl& url) | |
| hzEcode | GetPage | (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. |
| hzEcode | PostAjax | (HttpRC& hRet)hzUrl& url, hzVect<hzString>& hdrs, hzList<hzPair>& formData, | Post a form to the server but do not seek a HTTP response. |
| hzEcode | PostForm | (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). |
| hzEcode | TestPage | (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. |
| hzEcode | UpgradeWS | (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:
| hzXDate | m_Accessed | Date of last access (downloaded). Derived from 'Date:' field in header. | |
| hzString | m_AltProto | The only expected value here is 'chunked' | |
| hzString | m_AuthBasic | If set, this is supplied with each GetPage() call. | |
| hzString | m_CacheCtrl | Cache control | |
| hzString | m_ContEncoding | Eg 'gzip' | |
| hzChain | m_Content | HTML page content of server's response | |
| hzString | m_ContentType | Content type | |
| hzMapS<hzString,hzCookie> | m_Cookies | Cookies applicable to the target website | |
| hzString | m_Encoding | Content encoding eg UTF-8 | |
| hzChain | m_Error | Error logging | |
| hzString | m_Etag | Entity tag if present in the header | |
| hzXDate | m_Expires | Date page expires (after which it must be re-loaded) | |
| hzChain | m_Header | Header of server's response | |
| hzString | m_Host | Domain name or host currently connected to | |
| hzString | m_KeepAlive | Keep-Alive parameters (currently ignored) | |
| hzXDate | m_Modified | Date of last modification (from header). Default will be date/time of download. | |
| hzString | m_Pragma | Pragma directive | |
| hzString | m_Redirect | Where to go to actually load the page | |
| hzUrl | m_Referer | Last page (used in constructing 'Referer:' header) | |
| hzChain | m_Request | Chain formed by GetHttpPage() to send a request to a server | |
| uint32_t | m_Retcode | HTML return code | |
| hzTcpClient | m_Webhost | Current connection | |
| hzString | m_XferEncoding | The only expected value here is 'chunked' | |
| bool | m_bChunked | Server's response was chunked (diagnostics only) | |
| bool | m_bConnection | True if server returns Keep-Alive | |
| char* | m_buf | Buffer for IP packets | |
| uint32_t | m_nContentLen | Content length | |
| uint32_t | m_nMaxConnects | Maximum connections (we only ever use one) | |
| uint32_t | m_nTimeout | Maximum timeout | |
| uint64_t | m_rtRequest | Request sent time | |
| uint64_t | m_rtResponse | Response complete time |