HTTP Client Class


Topics:

Overview
Constants
Type Definitions
Data Members
Functions


Overview

The HTTP client class is used to retrieve Web pages from an HTTP server.


Constants

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

// Adjust these values for maximum performance
const int __HTTP_CACHE_SIZE__  = 1024;  // Number of cache buckets used
const int __HTTP_PACKET_SIZE__ = 32767; // Maximum packet size 


Type Definitions

typedef MemoryBuffer MEMTYPE; // Resizable memory buffers
typedef gxDeviceCachePtr httpCachePointer; // Pointer to the device cache


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.

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

gxString gxsHTTPClient::HTTP_AGENT_STRING - Application name string. Defaults to: "User-Agent: gxsHTTPLibrary/4000.101\r\n"

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

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

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

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

gxString gxsHTTPClient::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"

gxString gxsHTTPClient::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"


Functions

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

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

gxsHTTPClient::~gxsHTTPClient() - Class destructor.

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

void gxsHTTPClient::BuildRequestString(const gxsURLInfo &u, int method, gxString &request) - Public member function used to build a request string.

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

int gxsHTTPClient::ConnectClient(const char *host, int port = gxSOCKET_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 gxsHTTPClient::Flush() - Public member function used to flush all the device cache buffers.

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

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

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

int gxsHTTPClient::ParseHTTPHeader(const gxsURLInfo &u, const gxString &header, gxsHTTPHeader &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 gxsHTTPClient::RequestFile(const gxsURLInfo &u, const gxsHTTPHeader &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 gxsHTTPClient::RequestFile(const gxsURLInfo &u, const gxsHTTPHeader &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 gxsHTTPClient::RequestHeader(const gxsURLInfo &u, gxsHTTPHeader &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 gxsHTTPClient::SimpleRequest(const gxsURLInfo &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 gxsHTTPClient::SimpleRequest(const gxsURLInfo &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.


End Of Document