/* ** (c) COPYRIGHT MIT 1995. ** Please first read the full copyright statement in the file COPYRIGH. */
The Host class manages what we know about a remote host. This can for example be what type of host it is, and what version it is using. Notice that a host object can be used to describe both a server or a client - all information in the Host object can be shared regardless of whether it is to be used in a server application or a client application.
This module is implemented by HTHost.c, and it is a part of the W3C Sample Code Library.
#ifndef HTHOST_H #define HTHOST_H typedef struct _HTHost HTHost; #define HOST_HASH_SIZE HT_M_HASH_SIZE #include "HTChannl.h" #include "HTReq.h" #include "HTEvent.h" #include "HTProt.h" #include "HTTimer.h"
The Host class contains information about the remote host, for example the type (HTTP/1.0, HTTP/1.1, FTP etc.) along with information on how the connections can be used (if it supports persistent connections, interleaved access etc.)
We keep a cache of information that we know about a remote host. This allows us to be much more detailed in generating requests. Search the host info cache for a host object or create a new one and add it. Examples of host names are
extern HTHost * HTHost_new (char * host, u_short u_port); extern HTHost * HTHost_newWParse(HTRequest * request, char * url, u_short u_port); extern int HTHost_hash (HTHost * host);
The Host Class contains an automatic garbage collection of Host objects so that we don't keep information around that is stale.
Searches the cache of known hosts to see if we already have information about this host. If not then we return NULL.
extern HTHost * HTHost_find (char * host);
Cleanup and delete the host table.
extern void HTHost_deleteAll (void);
You can use this function to see whether a host object is idle or in use. We have several modes describing how and when a host is idle. This is a function of the Transport Object
extern BOOL HTHost_isIdle (HTHost * host);
We keep track of the capabilities of the host in the other end so thatwe may adjust our queries to fit it better
Get the name of the remote host. This is set automatically when a new Host object and can be asked for at any point in time. You can not change the host name but must create a new Host object instead.
extern char * HTHost_name (HTHost * host);
Define the host class of the host at the other end. A class is a generic description of the protocol which is exactly like the access method in a URL, for example "http" etc. The host version is a finer distinction (sub-class) between various versions of the host class, for example HTTP/0.9, HTTP/1.1 etc. The host version is a bit flag that the protocol module can define on its own. That way we don't have to change this module when registering a new protocol module. The host type is a description of whether we can keep the connection persistent or not.
extern char * HTHost_class (HTHost * host); extern void HTHost_setClass (HTHost * host, char * s_class); extern int HTHost_version (HTHost * host); extern void HTHost_setVersion (HTHost * host, int version);
A server can inform a client about the supported methods using the
Public header.
extern HTMethod HTHost_publicMethods (HTHost * me); extern void HTHost_setPublicMethods (HTHost * me, HTMethod methodset); extern void HTHost_appendPublicMethods (HTHost * me, HTMethod methodset);
A server can send its server application name and version in a HTTP response. We pick up this information and add it to the Host object
extern char * HTHost_server (HTHost * host); extern BOOL HTHost_setServer (HTHost * host, const char * server);
A client can send the name of the client application in a HTTP request. We pick up this information and add it to the Host Object
extern char * HTHost_userAgent (HTHost * host); extern BOOL HTHost_setUserAgent (HTHost * host, const char * userAgent);
Since all HTTP entities are represented in HTTP messages as sequences of bytes, the concept of a byte range is meaningful for any HTTP entity. (However, not all clients and servers need to support byte-range operations.) Byte range specifications in HTTP apply to the sequence of bytes in the entity-body (not necessarily the same as the message-body). A byte range operation may specify a single range of bytes, or a set of ranges within a single entity.
You can also check whether a specific range unit is OK. WeIGH. */ > extern BOOL HTHistory_replace (HTHistory *hist, HTAnchor *cur);
extern BOOL HTHistory_removeLast (HTHistory *hist);
extern BOOL HTHistory_removeFrom (HTHistory *hist, int pos);
extern int HTHistory_count (HTHistory *hist);
extern int HTHistory_position (HTHistory *hist);
extern HTAnchor * HTHistory_recall (HTHistory *hist, int pos);
HTHistory_recall but without re-registration. Un success,
the current position is updated to the value 'pos' value.
extern HTAnchor * HTHistory_find (HTHistory *hist, int pos);
HTHistory_find() but does
not update the current position
extern HTAnchor * HTHistory_list (HTHistory *hist, int pos);
extern BOOL HTHistory_canBacktrack (HTHistory *hist);
extern HTAnchor * HTHistory_backtrack (HTHistory *hist);
extern HTAnchor * HTHistory_back (HTHistory *hist);
extern BOOL HTHistory_canForward (HTHistory *hist);
extern HTAnchor * HTHistory_forward (HTHistory *hist); #endif /* HTHISTORY_H */