org.w3c.www.protocol.http.cache.push
Class PushCacheProtocol

java.lang.Object
  extended by org.w3c.www.protocol.http.cache.push.PushCacheProtocol

public class PushCacheProtocol
extends java.lang.Object

PushCacheProtocol Characteristics of the protocol used to control the push cache, and methods for common operations

Protocol Description

To request that "/home/abc/page.html" is inserted in cache as "http://www.abc.com/page.html" the client sends a packet with command="ADD", and remain_len set to sizeof(add_packet_t) plus the sum of the lengths of the path and the urls including their null terminators. The client then sends an add_packet describing the lengths of the two strings followed by the path and then the url.

The server replies with either command="OK" and remain_len=0 or command="ERR" and remain_len set the the length of the error string that follows immediately. In the event of an "ERR" message the connection is closed by the server.

To request that the page associated with "http://www.abc.com/page.html" be removed from the cache the client sends a packet with command="DEL", and remain_len set to sizeof(int) plus the length of the url string including the trailing null character. The server replies as with ADD above. Attempting to remove a url that is not present in the cache results in an "OK" packet being returned, the cache is unchanged.

The client can ask if a url is present in the cache by sending a packet with command="PRS", and url information as with the DEL command. The server will reply with "OK" if the url is present, "NO" if the url is not present and "ERR" if an error was encountered.

The client can request that the cache be emptied of all urls by sending a packet with command="CLN" (clean). The remain_len field is set to zero. The server will reply with either OK or ERR.

The client can terminate the dialogue by sending a command="BYE" packet and then closing the connection.

'C' code describing the packet structures are shown below

 typedef struct {
                             // Bytes  Notes
                             // -----  -----
       char  tag[4];         // 0-3    = {'P','C','P','P'}
       short major_version;  // 4-5    = 1
       short minor_version;  // 6-7    = 1
       char  command[4];     // 8-11   Null terminated command string 
       int   remain_len;     // 12-15  number of remaining bytes to read
 } packet_t;

 typedef struct {
       int   path_len;       // 4      Length of pathname (including null)
       int   url_len;        // 8      Length of URL (including null)
 } add_packet_t;
 
 Note that the command is always 4 characters in length and that the
 null characters are considered part of the command, so in Java (but
 not C) we must include the \0 when comparing strings:
   "ADD\0", "BYE\0", "OK\0\0", "ERR\0", "CLN\0", "PRS\0", "DEL\0"

 


Field Summary
static int ADD
          Numeric codes for commands,
static int BYE
          Numeric codes for commands,
static int CLN
          Numeric codes for commands,
static int COMMAND_LEN
          Size of command string in bytes (including null terminator)
static int DEL
          Numeric codes for commands,
static int ERR
          Numeric codes for commands,
static int HEADER_LEN
          Combined size of tag and version information
static short MAJ_PROTO_VERSION
          Protocol Major version
static int MAX_PAYLOAD_LEN
          Maximum size of payload (follows basic packet)
static int MAX_STRING_LEN
          Maximum size of strings (urls, paths, error messages)
static short MIN_PROTO_VERSION
          Protocol minor version
static int NO
          Numeric codes for commands,
static int NO_SUCH_COMMAND
          Numeric codes for commands,
static int NOP
          Numeric codes for commands,
static int OK
          Numeric codes for commands,
static int PACKET_LEN
          Size of basic packet in bytes
static int PRS
          Numeric codes for commands,
static int TAG_LEN
          Size of packet tag
 
Constructor Summary
protected PushCacheProtocol()
          Singleton, no public constructor, use instance()
 
Method Summary
 byte[] errorPacket(java.lang.String message)
          Create error packet for specified error message
 byte[] header()
           
static PushCacheProtocol instance()
          Access to single instance of this class
 boolean isValidProtocolTag(byte[] packet)
          True iff first four bytes of packet are identical to the protocol tag
 byte[] noPacket()
          Byte array for NO packet
 byte[] okPacket()
          Byte array for OK packet
 int parseCommand(java.lang.String command)
          Utility function for command string parsing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PACKET_LEN

public static final int PACKET_LEN
Size of basic packet in bytes

See Also:
Constant Field Values

COMMAND_LEN

public static final int COMMAND_LEN
Size of command string in bytes (including null terminator)

See Also:
Constant Field Values

HEADER_LEN

public static final int HEADER_LEN
Combined size of tag and version information

See Also:
Constant Field Values

TAG_LEN

public static final int TAG_LEN
Size of packet tag

See Also:
Constant Field Values

MAX_STRING_LEN

public static final int MAX_STRING_LEN
Maximum size of strings (urls, paths, error messages)

See Also:
Constant Field Values

MAX_PAYLOAD_LEN

public static final int MAX_PAYLOAD_LEN
Maximum size of payload (follows basic packet)

See Also:
Constant Field Values

MAJ_PROTO_VERSION

public static final short MAJ_PROTO_VERSION
Protocol Major version

See Also:
Constant Field Values

MIN_PROTO_VERSION

public static final short MIN_PROTO_VERSION
Protocol minor version

See Also:
Constant Field Values

NO_SUCH_COMMAND

public static final int NO_SUCH_COMMAND
Numeric codes for commands,

See Also:
Constant Field Values

ERR

public static final int ERR
Numeric codes for commands,

See Also:
Constant Field Values

ADD

public static final int ADD
Numeric codes for commands,

See Also:
Constant Field Values

DEL

public static final int DEL
Numeric codes for commands,

See Also:
Constant Field Values

CLN

public static final int CLN
Numeric codes for commands,

See Also:
Constant Field Values

PRS

public static final int PRS
Numeric codes for commands,

See Also:
Constant Field Values

BYE

public static final int BYE
Numeric codes for commands,

See Also:
Constant Field Values

OK

public static final int OK
Numeric codes for commands,

See Also:
Constant Field Values

NO

public static final int NO
Numeric codes for commands,

See Also:
Constant Field Values

NOP

public static final int NOP
Numeric codes for commands,

See Also:
Constant Field Values
Constructor Detail

PushCacheProtocol

protected PushCacheProtocol()
Singleton, no public constructor, use instance()

See Also:
instance()
Method Detail

instance

public static PushCacheProtocol instance()
Access to single instance of this class


parseCommand

public int parseCommand(java.lang.String command)
Utility function for command string parsing


okPacket

public byte[] okPacket()
Byte array for OK packet


noPacket

public byte[] noPacket()
Byte array for NO packet


header

public byte[] header()

errorPacket

public byte[] errorPacket(java.lang.String message)
Create error packet for specified error message


isValidProtocolTag

public boolean isValidProtocolTag(byte[] packet)
True iff first four bytes of packet are identical to the protocol tag