com.eyebolt.iplib
Class HttpHeader

java.lang.Object
  |
  +--com.eyebolt.iplib.MessageHeader
        |
        +--com.eyebolt.iplib.HttpHeader

public class HttpHeader
extends MessageHeader

Header prepended to every ipmanager BASE message

Version:
0.01, 10 Sep 2001
Author:
John Gardner

Inner Class Summary
(package private) static class HttpHeader.HttpHeaderLine
           
(package private) static class HttpHeader.ParseState
           
 
Field Summary
static int ACCEPTED
           
static int BAD_GATEWAY
           
static int BAD_REQUEST
           
static byte[] byteArrayVersion
          The version we emit with all replies.
static int CONFLICT
           
private static byte[] contentLengthHdr
           
private static byte[] contentTypeHdr
           
private static byte[] contentTypeValue
           
static int CONTINUE
           
static int CREATED
           
private static boolean debug
           
static int EXPECTATION_FAILED
           
private  int flags
           
static int FORBIDDEN
           
static int FOUND
           
static int GATEWAY_TIMEOUT
           
(package private) static int globalId
          class variable for message id
static int GONE
           
private  boolean hasIpLibBody
           
private  HttpHeader.HttpHeaderLine[] headerLines
          Vector of byte arrays that are lines of HTTP header
static int HTTP_VERSION_NOT_SUPPORTED
           
private static byte[] httpHdr
           
static int INTERNAL_SERVER_ERROR
           
static short IPLIB_HEADER_SIZE
          Description of the Field
private  short length
           
static int LENGTH_REQUIRED
           
private  int messageId
           
private  int messageLength
           
private  int messageResponseId
           
static int MOVED_PERMANENTLY
           
static java.lang.String[] msg_100
           
static java.lang.String[] msg_200
           
static java.lang.String[] msg_300
           
static java.lang.String[] msg_400
           
static java.lang.String[] msg_500
           
static int MSG_SIGNATURE
          Description of the Field
static int MULTIPLE_CHOICE
           
static int NO_CONTENT
           
static int NON_AUTHORITATIVE_INFORMATION
           
static int NOT_ACCEPTABLE
           
static int NOT_ALLOWED
           
static int NOT_EXTENDED
           
static int NOT_FOUND
           
static int NOT_IMPLEMENTED
           
static int NOT_MODIFIED
           
static int OK
           
private  int packetSize
           
static int PARTIAL_CONTENT
           
static int PAYMENT_REQUIRED
           
static int PRECONDITION_FAILED
           
static int PROXY_AUTH_REQUIRED
           
private  IPAddress remoteAddress
          Address of the other end
static int REQUEST_ENTITY_TOO_LARGE
           
static int REQUEST_TIMEOUT
           
static int REQUEST_URI_TOO_LONG
           
static int REQUESTED_RANGE_NOT_SATISFIABLE
           
static int RESET_CONTENT
           
static int SEE_OTHER
           
private  short sequenceNum
           
private  byte[] serializedHttp
           
private  boolean serverMode
           
private  short service
           
static int SERVICE_UNAVAILABLE
           
private  int signature
           
static int SWITCHING
           
static int TEMPORARY_REDIRECT
           
static int UNAUTHORIZED
           
static int UNSUPPORTED_MEDIA_TYPE
           
static int USE_PROXY
           
private  short version
           
 
Fields inherited from class com.eyebolt.iplib.MessageHeader
FLAG_BEACON, FLAG_MESSAGE_ACK, FLAG_MESSAGE_CANCEL, FLAG_MESSAGE_CRC, FLAG_MESSAGE_RETRY, FLAG_PING, Flags, globalID, HdrCRC, HdrLen, MAX_SIZE, message, MSG_VERSION, MsgId, MsgLen, PktLen, SeqNum, Service, Signature, SVC_DISCONNECT, SVC_NORMAL, SVC_VERIFYCONNECTION, Version
 
Constructor Summary
HttpHeader()
          Constructor for the HttpHeader object
HttpHeader(IPMessage msg)
          Constructor for the HttpHeader object
HttpHeader(IPMessage msg, IPAddress remoteAddress)
          Constructor for the HttpHeader object
 
Method Summary
(package private)  void ()
           
(package private) static boolean checkHdr(byte[] buffer, int offset, int len)
          Validate this stream of bytes as an HTTP header
(package private) static boolean checkRequestHdr(byte[] buffer, int offset, int len)
          Validate this stream of bytes as an HTTP header
(package private) static boolean checkResponseHdr(byte[] buffer, int offset, int len)
          Validate this stream of bytes as an HTTP header
 int flattenAt(byte[] buf)
          Description of the Method
(package private)  void flattenHeader()
          Serialize HTTP header
(package private)  int getId()
          Fetch the message Id
(package private)  short getLength()
          Fetch the header length
(package private)  int getMessageLength()
          Fetch the message length
(package private)  java.lang.String getMethod()
          Fetch the message method type
static int getMinimumSize()
          Gets the Size attribute of the HttpHeader class
(package private)  IPAddress getRemoteAddress()
          Return the address of the remote machine.
(package private)  int getResponseId()
          Fetch the message ResponseId
(package private)  short getServiceType()
          Fetch the message service type
 int getSize()
          Gets the Size attribute of the HttpHeader class
(package private)  java.lang.String getTarget()
          Fetch the message target type
(package private)  boolean hasFlag(int flag)
          Return true if a flag is set on this message header.
(package private)  void makeId()
          Assign the header a new unique message Id
(package private) static int nextItem(byte[] buf, HttpHeader.ParseState ps)
          Parse list of items, taking care of quotes and optional LWS.
(package private)  int parseHttpRequestHeader(byte[] buf)
          Fill this header with the contents of the input buffer.
(package private)  int parseHttpResponseHeader(byte[] buf)
          Fill this header with the contents of the input buffer.
(package private) static int parseInt(byte[] buf, HttpHeader.ParseState ps)
           
(package private) static int parseInt(byte[] buf, int radix, HttpHeader.ParseState ps)
          Parse an integer, and return an updated pointer.
(package private)  void setFlag(int flag)
          Set a flag value
(package private)  void setId(int id)
          Sets the Id attribute of the HttpHeader object
(package private)  void setLength(short length)
          Sets the length of the HttpHeader
(package private)  void setMessageLength(int length)
          Sets the length of the message for which this is a header
(package private)  void setMethod(java.lang.String method)
          Sets the method attribute of the HttpHeader object
(package private)  void setRemoteAddress(IPAddress address)
          Set the address of the remote machine.
(package private)  void setResponseId(int id)
          Sets the Id attribute of the HttpHeader object
(package private)  void setServiceType(short serviceId)
          Sets the service attribute of the HttpHeader object
(package private)  void setTarget(java.lang.String target)
          Sets the target attribute of the HttpHeader object
(package private) static int skipSpaces(byte[] buf, HttpHeader.ParseState ps)
          Skip leading LWS, not including CR LF.
 java.lang.String toString()
          Description of the Method
(package private)  int unFlattenFrom(byte[] buf)
          Fill this header with the contents of the input buffer.
 void updateValues()
          Recalculate header values, recompute flattened size, based on possible header changes.
 
Methods inherited from class com.eyebolt.iplib.MessageHeader
getBaseSize, getID, makeID, setID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

MSG_SIGNATURE

public static final int MSG_SIGNATURE
Description of the Field

byteArrayVersion

public static final byte[] byteArrayVersion
The version we emit with all replies. This version matches the version understood by the API, which does not necessarily reflect what is returned by getMajorVersion and getMinorVersion.

msg_100

public static final java.lang.String[] msg_100

msg_200

public static final java.lang.String[] msg_200

msg_300

public static final java.lang.String[] msg_300

msg_400

public static final java.lang.String[] msg_400

msg_500

public static final java.lang.String[] msg_500

CONTINUE

public static final int CONTINUE

SWITCHING

public static final int SWITCHING

OK

public static final int OK

CREATED

public static final int CREATED

ACCEPTED

public static final int ACCEPTED

NON_AUTHORITATIVE_INFORMATION

public static final int NON_AUTHORITATIVE_INFORMATION

NO_CONTENT

public static final int NO_CONTENT

RESET_CONTENT

public static final int RESET_CONTENT

PARTIAL_CONTENT

public static final int PARTIAL_CONTENT

MULTIPLE_CHOICE

public static final int MULTIPLE_CHOICE

MOVED_PERMANENTLY

public static final int MOVED_PERMANENTLY

FOUND

public static final int FOUND

SEE_OTHER

public static final int SEE_OTHER

NOT_MODIFIED

public static final int NOT_MODIFIED

USE_PROXY

public static final int USE_PROXY

TEMPORARY_REDIRECT

public static final int TEMPORARY_REDIRECT

BAD_REQUEST

public static final int BAD_REQUEST

UNAUTHORIZED

public static final int UNAUTHORIZED

PAYMENT_REQUIRED

public static final int PAYMENT_REQUIRED

FORBIDDEN

public static final int FORBIDDEN

NOT_FOUND

public static final int NOT_FOUND

NOT_ALLOWED

public static final int NOT_ALLOWED

NOT_ACCEPTABLE

public static final int NOT_ACCEPTABLE

PROXY_AUTH_REQUIRED

public static final int PROXY_AUTH_REQUIRED

REQUEST_TIMEOUT

public static final int REQUEST_TIMEOUT

CONFLICT

public static final int CONFLICT

GONE

public static final int GONE

LENGTH_REQUIRED

public static final int LENGTH_REQUIRED

PRECONDITION_FAILED

public static final int PRECONDITION_FAILED

REQUEST_ENTITY_TOO_LARGE

public static final int REQUEST_ENTITY_TOO_LARGE

REQUEST_URI_TOO_LONG

public static final int REQUEST_URI_TOO_LONG

UNSUPPORTED_MEDIA_TYPE

public static final int UNSUPPORTED_MEDIA_TYPE

REQUESTED_RANGE_NOT_SATISFIABLE

public static final int REQUESTED_RANGE_NOT_SATISFIABLE

EXPECTATION_FAILED

public static final int EXPECTATION_FAILED

INTERNAL_SERVER_ERROR

public static final int INTERNAL_SERVER_ERROR

NOT_IMPLEMENTED

public static final int NOT_IMPLEMENTED

BAD_GATEWAY

public static final int BAD_GATEWAY

SERVICE_UNAVAILABLE

public static final int SERVICE_UNAVAILABLE

GATEWAY_TIMEOUT

public static final int GATEWAY_TIMEOUT

HTTP_VERSION_NOT_SUPPORTED

public static final int HTTP_VERSION_NOT_SUPPORTED

NOT_EXTENDED

public static final int NOT_EXTENDED

IPLIB_HEADER_SIZE

public static final short IPLIB_HEADER_SIZE
Description of the Field

httpHdr

private static final byte[] httpHdr

contentLengthHdr

private static final byte[] contentLengthHdr

contentTypeHdr

private static final byte[] contentTypeHdr

contentTypeValue

private static final byte[] contentTypeValue

globalId

static int globalId
class variable for message id

signature

private int signature

version

private short version

service

private short service

length

private short length

packetSize

private int packetSize

messageLength

private int messageLength

messageId

private int messageId

messageResponseId

private int messageResponseId

sequenceNum

private short sequenceNum

flags

private int flags

serverMode

private boolean serverMode

hasIpLibBody

private boolean hasIpLibBody

debug

private static boolean debug

remoteAddress

private IPAddress remoteAddress
Address of the other end

headerLines

private HttpHeader.HttpHeaderLine[] headerLines
Vector of byte arrays that are lines of HTTP header

serializedHttp

private byte[] serializedHttp
Constructor Detail

HttpHeader

public HttpHeader()
Constructor for the HttpHeader object

HttpHeader

public HttpHeader(IPMessage msg)
Constructor for the HttpHeader object
Parameters:
msg - Description of Parameter

HttpHeader

public HttpHeader(IPMessage msg,
                  IPAddress remoteAddress)
Constructor for the HttpHeader object
Parameters:
msg - Description of Parameter
Method Detail

updateValues

public void updateValues()
Recalculate header values, recompute flattened size, based on possible header changes.
Overrides:
updateValues in class MessageHeader

flattenAt

public int flattenAt(byte[] buf)
Description of the Method
Overrides:
flattenAt in class MessageHeader
Parameters:
buf - Description of Parameter
Returns:
Description of the Returned Value

flattenHeader

void flattenHeader()
Serialize HTTP header

checkHdr

static boolean checkHdr(byte[] buffer,
                        int offset,
                        int len)
Validate this stream of bytes as an HTTP header
Parameters:
buffer - bytes to check
offset - offset from beginning of buffer at which header starts.
len - how many bytes to check, maximum
Returns:
true if this is a complete header

unFlattenFrom

int unFlattenFrom(byte[] buf)
Fill this header with the contents of the input buffer.
Overrides:
unFlattenFrom in class MessageHeader
Parameters:
buf - buffer to unflatten from.
Returns:
number of bytes consumed

parseHttpRequestHeader

int parseHttpRequestHeader(byte[] buf)
Fill this header with the contents of the input buffer.
Parameters:
buf - buffer to unflatten from.
Returns:
number of bytes consumed

parseHttpResponseHeader

int parseHttpResponseHeader(byte[] buf)
Fill this header with the contents of the input buffer.
Parameters:
buf - buffer to unflatten from.
Returns:
number of bytes consumed

toString

public java.lang.String toString()
Description of the Method
Overrides:
toString in class MessageHeader
Returns:
Description of the Returned Value

getSize

public int getSize()
Gets the Size attribute of the HttpHeader class
Overrides:
getSize in class MessageHeader
Returns:
The Size value

getMinimumSize

public static int getMinimumSize()
Gets the Size attribute of the HttpHeader class
Returns:
The Size value

getRemoteAddress

IPAddress getRemoteAddress()
Return the address of the remote machine.
Returns:
remote machine address

setRemoteAddress

void setRemoteAddress(IPAddress address)
Set the address of the remote machine.
Parameters:
address - machine address

setFlag

void setFlag(int flag)
Set a flag value
Overrides:
setFlag in class MessageHeader
Parameters:
flag - flag to set

hasFlag

boolean hasFlag(int flag)
Return true if a flag is set on this message header.
Overrides:
hasFlag in class MessageHeader
Parameters:
flag - flag to check

setId

void setId(int id)
Sets the Id attribute of the HttpHeader object
Overrides:
setId in class MessageHeader
Parameters:
id - The new Id value

getId

int getId()
Fetch the message Id
Overrides:
getId in class MessageHeader
Returns:
The Id value

setResponseId

void setResponseId(int id)
Sets the Id attribute of the HttpHeader object
Overrides:
setResponseId in class MessageHeader
Parameters:
id - The new ResponseId value

getResponseId

int getResponseId()
Fetch the message ResponseId
Overrides:
getResponseId in class MessageHeader
Returns:
The ResponseId value

setLength

void setLength(short length)
Sets the length of the HttpHeader
Parameters:
id - The new length value

getLength

short getLength()
Fetch the header length
Returns:
The length value

setMessageLength

void setMessageLength(int length)
Sets the length of the message for which this is a header
Parameters:
id - The new length value

getMessageLength

int getMessageLength()
Fetch the message length
Returns:
The length value

setServiceType

void setServiceType(short serviceId)
Sets the service attribute of the HttpHeader object
Overrides:
setServiceType in class MessageHeader
Parameters:
service - The new service value

getServiceType

short getServiceType()
Fetch the message service type
Overrides:
getServiceType in class MessageHeader
Returns:
The service type value

setMethod

void setMethod(java.lang.String method)
Sets the method attribute of the HttpHeader object
Parameters:
method - The new method value

getMethod

java.lang.String getMethod()
Fetch the message method type
Returns:
The method type value

setTarget

void setTarget(java.lang.String target)
Sets the target attribute of the HttpHeader object
Parameters:
target - The new target value

getTarget

java.lang.String getTarget()
Fetch the message target type
Returns:
The target type value

makeId

void makeId()
Assign the header a new unique message Id

checkRequestHdr

static boolean checkRequestHdr(byte[] buffer,
                               int offset,
                               int len)
Validate this stream of bytes as an HTTP header
Parameters:
buffer - bytes to check
offset - offset from beginning of buffer at which header starts.
len - how many bytes to check, maximum
Returns:
true if this is a complete header

checkResponseHdr

static boolean checkResponseHdr(byte[] buffer,
                                int offset,
                                int len)
Validate this stream of bytes as an HTTP header
Parameters:
buffer - bytes to check
offset - offset from beginning of buffer at which header starts.
len - how many bytes to check, maximum
Returns:
true if this is a complete header

skipSpaces

static final int skipSpaces(byte[] buf,
                            HttpHeader.ParseState ps)
Skip leading LWS, not including CR LF. Update the input offset, after any leading space.
Parameters:
buf - The buffer to be parsed.
ptr - The buffer pointer to be updated on return.
Returns:
The potentially advanced buffer input offset.

nextItem

static final int nextItem(byte[] buf,
                          HttpHeader.ParseState ps)
Parse list of items, taking care of quotes and optional LWS. The output offset points to the next element of the list.

parseInt

static final int parseInt(byte[] buf,
                          int radix,
                          HttpHeader.ParseState ps)
Parse an integer, and return an updated pointer.

parseInt

static final int parseInt(byte[] buf,
                          HttpHeader.ParseState ps)

void ()
Overrides:
in class java.lang.Object


Copyright © 2001 Eyebolt, Inc.