|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.w3c.www.protocol.http.cache.push.PushCacheProtocol
public class PushCacheProtocol
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 |
---|
public static final int PACKET_LEN
public static final int COMMAND_LEN
public static final int HEADER_LEN
public static final int TAG_LEN
public static final int MAX_STRING_LEN
public static final int MAX_PAYLOAD_LEN
public static final short MAJ_PROTO_VERSION
public static final short MIN_PROTO_VERSION
public static final int NO_SUCH_COMMAND
public static final int ERR
public static final int ADD
public static final int DEL
public static final int CLN
public static final int PRS
public static final int BYE
public static final int OK
public static final int NO
public static final int NOP
Constructor Detail |
---|
protected PushCacheProtocol()
instance()
instance()
Method Detail |
---|
public static PushCacheProtocol instance()
public int parseCommand(java.lang.String command)
public byte[] okPacket()
public byte[] noPacket()
public byte[] header()
public byte[] errorPacket(java.lang.String message)
public boolean isValidProtocolTag(byte[] packet)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |