VBS HTTP Client Class


Topics:

Overview
Constants
Type Definitions
Functions
Public Data Members


Overview

HTTP client class used to retrieve Web pages from an HTTP server. The VBS HTTP client class is supplied with the database library to extract data from html documents.


Constants

const int __HTTP_DEFAULT_CACHE_SIZE__  = 1024;  // Default cache size  
const int __HTTP_DEFAULT_PACKET_SIZE__ = 1024;  // Max block length 


Type Definitions

typedef MemoryBuffer MEMTYPE; // Variable length memory buffers
typedef vbDeviceCachePtr httpCachePointer; // Pointer to the device cache


Functions

vbsHTTPClient::vbsHTTPClient()
vbsHTTPClient::~vbsHTTPClient()
vbsHTTPClient::BucketsInUse()
vbsHTTPClient::BuildRequestString()
vbsHTTPClient::BuildSimpleRequestString()
vbsHTTPClient::ConnectClient()
vbsHTTPClient::Flush()
vbsHTTPClient::GetCache()
vbsHTTPClient::GetMethod()
vbsHTTPClient::GetProtocolString()
vbsHTTPClient::ParseHTTPHeader()
vbsHTTPClient::RequestFile()
vbsHTTPClient::RequestHeader()
vbsHTTPClient::SimpleRequest()

vbsHTTPClient::vbsHTTPClient(int CacheSize = __HTTP_DEFAULT_CACHE_SIZE__) - Class constructor used to construct a new HTTP client and set the device cache size.

vbsHTTPClient::~vbsHTTPClient() - Class destructor.

unsigned vbsHTTPClient::BucketsInUse() - Public member function used to retrieve the total number of device cache buckets in used.

void vbsHTTPClient::BuildRequestString(const vbsURLInfo &u, int method, vbString &request) - Public member function used to build a request string.

void vbsHTTPClient::BuildSimpleRequestString(const vbsURLInfo &u, int method, vbString &request) -Public member function used to build a request simple string. When a simple request string is used the server will not send an HTTP header with the requested document.

int vbsHTTPClient::ConnectClient(const char *host, int port = vbSOCKET_HTTP_PORT) - Public member function used to connect a client to an HTTP server. Returns zero if no errors occur or a non-zero value to indicate a failure.

void vbsHTTPClient::Flush() - Public member function used to flush all the device cache buffers.

vbDeviceBucketCache *vbsHTTPClient::GetCache() - Public member function used to retrieve the bucket cache.

char *vbsHTTPClient::GetMethod(int method) - Public member function that returns a null terminated string corresponding to the specified method.

char *vbsHTTPClient::GetProtocolString(int protocol) - Public member function that returns a null terminated string corresponding to the specified protocol.

int vbsHTTPClient::ParseHTTPHeader(const vbsURLInfo &u, const vbString &header, vbsHTTPHeader &hdr) - Public member function used to parse HTTP headers received from an HTTP server. Returns zero if no errors occur or a non-zero value to indicate a failure.

int vbsHTTPClient::RequestFile(const vbsURLInfo &u, const vbsHTTPHeader &hdr, fstream *stream) -Public member function used to request a file and write it to the specified stream. This function assumes that the document header has already been requested and placed in the "hdr" variable. Returns zero if no errors occur or a non-zero value to indicate a failure.

int vbsHTTPClient::RequestFile(const vbsURLInfo &u, const vbsHTTPHeader &hdr, MemoryBuffer &mbuf) - Public member function used to request a file and write it to a memory buffer. This function assumes that the document header has already been requested and placed in the "hdr" variable. Returns zero if no errors occur or a non-zero value to indicate a failure.

int vbsHTTPClient::RequestHeader(const vbsURLInfo &u, vbsHTTPHeader &hdr) -Public member function used to request a document header passing back the header information in the "hdr" variable. Returns zero if no errors occur or a non-zero value to indicate a failure.

int vbsHTTPClient::SimpleRequest(const vbsURLInfo &u, fstream *stream) - Public member function used to request a document with no header information and write it to the specified stream. Returns zero if no errors occur or a non-zero value to indicate a failure.

int vbsHTTPClient::SimpleRequest(const vbsURLInfo &u, MemoryBuffer &mbuf) - Public member function used to request a document with no header information and write it to the specified memory buffer. Returns zero if no errors occur or a non-zero value to indicate a failure.


Public Data Members

Client header strings that can or must be modified according to the application. These values will be used when a request string is built.

vbString vbsHTTPClient::HTTP_VERSION_STRING - HTTP requested version string. "Defaults to: HTTP/1.0\r\n"

vbString vbsHTTPClient::HTTP_AGENT_STRING - Application name string. Defaults to: "User-Agent: vbsHTTPLibrary/1034.101\r\n"

vbString vbsHTTPClient::HTTP_ACCEPT_STRING - File types that will be accepted. Defaults to: "Accept: */*\r\n"

vbString vbsHTTPClient::HTTP_PRAGMA_STRING - Implementation-specific directives. Defaults to: "Pragma: no-cache\r\n"

vbString vbsHTTPClient::HTTP_COOKIE_STRING - Used to provide information left earlier by some server. Usage: "Cookie: persistent data\r\n" Defaults to: NULL

vbString vbsHTTPClient::HTTP_DEFAULT_FILE_REQUEST_STRING - Default file name used if no file is specified in the HTTP request string. Defaults to " /"

vbString vbsHTTPClient::HTTP_REFERER_STRING - The Referer request-header field allows the client to specify, for the server's benefit, the address (URI) of the resource from which the Request-URI was obtained. This value will be set to NULL by default. Usage example: "Referer: http://www.w3.org/hypertext/DataSources/Overview.html\r\n"

vbString vbsHTTPClient::HTTP_IF_MOD_STRING - Used with the GET method to make it conditional: if the requested resource has not been modified since the time specified in this field, a copy of the resource will not be returned from the server; instead, a 304 (not modified) response will be returned without any Entity-Body. This value will be set to NULL by default. The application must set this value in order to include it in the request string. Usage example: "If-Modified-Since: Sat, 29 Oct 1999 19:43:31 GMT\r\n"


End Of Document