All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.www.http.HttpMessage

java.lang.Object
   |
   +----w3c.www.http.HttpMessage

public class HttpMessage
extends Object
implements MimeHeaderHolder, Cloneable, HTTP
The basic class for all HTTP messages, as define in the HTTP spec. This class is the base class for a number of other classes, including both the ingoing/outgoing requests and replies.


Variable Index

 o descriptors
 o EMIT_ALL
 o EMIT_BODY
 o EMIT_FOOTERS
 o EMIT_HEADERS
 o emitdate
The date at which this message was last emitted.
 o factory
The header value factory.
 o H_CACHE_CONTROL
 o H_CONNECTION
 o H_COOKIE
 o H_DATE
 o H_PRAGMA
 o H_PROTOCOL
 o H_PROTOCOL_INFO
 o H_PROTOCOL_QUERY
 o H_PROTOCOL_REQUEST
 o H_PROXY_CONNECTION
 o H_SET_COOKIE
 o H_TRANSFER_ENCODING
 o H_UPGRADE
 o H_VIA
 o headers
The header value repository.
 o major
The major version of this message, according to HTTP specs.
 o MAX_HEADERS
 o minor
The minoir version of this message, according to HTTP specs.
 o state
The state dictionary.
 o values

Constructor Index

 o HttpMessage()
 o HttpMessage(MimeParser)

Method Index

 o addConnection(String)
Add the given header name to the Connection header.
 o addNoCache(String)
Add the given header name to the no-cache directive.
 o addPragma(String)
Add the given directive to the Pragma header.
 o addProxyConnection(String)
Add the given header name to the Proxy-Connection header.
 o addVia(String)
Add a via clause to the via header.
 o checkNoStore()
Check the no-store directive of the cache control header.
 o checkOnlyIfCached()
Check the only-if-cached directive.
 o delState(String)
State management - Remove a piece of state from this request.
 o dump(OutputStream)
 o emit(OutputStream)
Emit this message to the given output stream.
 o emit(OutputStream, int)
 o emitHeaders(OutputStream, int)
 o endEmit(OutputStream, int)
This message has been emited.
 o enumerateHeaderDescriptions()
Enumerate all the headers defined for that message.
 o enumerateHeaderDescriptions(boolean)
Enumerate all the available headers for that message.
 o getCacheControl()
Header accessor - get the cache control policy.
 o getClone()
Get a clone of this HTTP message.
 o getConnection()
Header accessor - get the connection header value.
 o getCookie()
Get the cookies attached to that message.
 o getDate()
Header accessor - get the date of this message.
 o getEmitDate()
Get the date at which this message was last emitted, if ever it was.
 o getHeaderValue(HeaderDescription)
Get a header value, keyed by it's header description.
 o getHeaderValue(int)
Fast access to header value.
 o getHeaderValue(String)
Get a header value by name.
 o getHeaderValue(String, HeaderValue)
Get a header value, given its name.
 o getMajorVersion()
Get the major version number of this message.
 o getMaxAge()
Get the max-age value for the current cache control.
 o getMinorVersion()
Get the minor version number of this message.
 o getNoCache()
Get the no-cache directive of the cache control header.
 o getPragma()
Header accessor - get the pragmas applicable to this message.
 o getProtocol()
Get the set of protocol extensions that have been aplpied to that that message.
 o getProtocolInfo()
Get the protocol extensions informations carried by this message.
 o getProtocolQuery()
Get the set of protocol extensions that are queried through this message.
 o getProtocolRequest()
Get the set of protocol extensions requested by this message.
 o getProxyConnection()
Header accessor - get the proxy connection header value.
 o getSetCookie()
Get the value of the SetCookie header.
 o getState(String)
State management - Lookup the value of a state on this request.
 o getTransferEncoding()
Header accessor - get the transfer encoding applying to this message.
 o getUpgrade()
Header accessor - get the upgrade header of this message.
 o getValue(HeaderDescription)
Get a header field value as a String.
 o getValue(String)
Get a header field value as a String.
 o getVersion()
Get the String identifying the HTTP version used for this message.
 o getVia()
Header accessor - get the via header of this message.
 o hasConnection(String)
Does the connection header include the given token ?
 o hasHeader(int)
Probe this message for a defined header, fast access !
 o hasHeader(String)
Probe this message for a defined header.
 o hasPragma(String)
Header accessor - Check for a given pragma.
 o hasProxyConnection(String)
Does the proxy connection header defines the given token.
 o hasState(String)
State management - Is the given state defined for the message ?
 o hasTransferEncoding(String)
Header accessor - Check for a given transfer encoding.
 o notifyBeginParsing(MimeParser)
MimeHeaderHolder implementation - HTTP message about to be parsed.
 o notifyEndParsing(MimeParser)
MimeHeaderHolder implementation - HTTP message parsing done.
 o notifyHeader(String, byte[], int, int)
MimeHeaderHolder implementation - The MIME parser callback.
 o registerHeader(String, String)
 o registerHeader(String, String, int)
 o removeHeader(int)
Remove a header, by address.
 o removeHeader(String)
Remove a header, by name.
 o setCacheControl(HttpCacheControl)
Header accessor - set the cache control associated with the message.
 o setConnection(String[])
Header accessor - set the connection header value.
 o setCookie(HttpCookieList)
Set the cookies attached to this message.
 o setDate(long)
Header accessor - set the date of this message.
 o setHeaderValue(HeaderDescription, HeaderValue)
Set a header value, keyed by it's header description.
 o setHeaderValue(int, HeaderValue)
Fast write accessor to headers.
 o setHeaderValue(String, HeaderValue)
Set a header value.
 o setMaxAge(int)
Set the max-age value of the associated cache control.
 o setNoCache()
Set the no-cache directive globally.
 o setNoCache(String[])
Set the no-cache directive of the cache control header.
 o setNoStore(boolean)
Set the no-store directive.
 o setOnlyIfCached(boolean)
Set the only-if-cached directive.
 o setPragma(String[])
Header accessor - set the pragmas applicable to this message.
 o setProtocol(HttpBag)
Set the protocol extensions applied to that message.
 o setProtocolInfo(HttpBag)
Attach protocol extensions informations to that message.
 o setProtocolQuery(HttpBag)
Set the protocol extensions queried by that message.
 o setProtocolRequest(HttpBag)
Set the protocol extensions required by this message.
 o setProxyConnection(String[])
Header accessor - set the proxy connection header value.
 o setSetCookie(HttpSetCookieList)
Set the value of the Set-Cookie header.
 o setState(String, Object)
State management - Add a piece of state to this request.
 o setTransferEncoding(String[])
Header accessor - set the transfer encoding for this message.
 o setUpgrade(String[])
Header accessor - set the upgrade header of this message.
 o setValue(String, String)
Define a new header field.
 o setVia(String[])
Header accessor - set the Via header of this message.
 o startEmit(OutputStream, int)
This message is about to be emited.

Variables

 o EMIT_HEADERS
 public static final int EMIT_HEADERS
 o EMIT_BODY
 public static final int EMIT_BODY
 o EMIT_FOOTERS
 public static final int EMIT_FOOTERS
 o EMIT_ALL
 public static final int EMIT_ALL
 o H_CACHE_CONTROL
 public static int H_CACHE_CONTROL
 o H_CONNECTION
 public static int H_CONNECTION
 o H_PROXY_CONNECTION
 public static int H_PROXY_CONNECTION
 o H_DATE
 public static int H_DATE
 o H_PRAGMA
 public static int H_PRAGMA
 o H_TRANSFER_ENCODING
 public static int H_TRANSFER_ENCODING
 o H_UPGRADE
 public static int H_UPGRADE
 o H_VIA
 public static int H_VIA
 o H_PROTOCOL
 public static int H_PROTOCOL
 o H_PROTOCOL_REQUEST
 public static int H_PROTOCOL_REQUEST
 o H_PROTOCOL_INFO
 public static int H_PROTOCOL_INFO
 o H_PROTOCOL_QUERY
 public static int H_PROTOCOL_QUERY
 o H_SET_COOKIE
 public static int H_SET_COOKIE
 o H_COOKIE
 public static int H_COOKIE
 o MAX_HEADERS
 public static int MAX_HEADERS
 o factory
 protected static Hashtable factory
The header value factory.

 o headers
 protected Dictionary headers
The header value repository. At this time, I am using this quite inefficient scheme, but the API have been carefully designed to enable a more efficient implementation.

 o major
 protected short major
The major version of this message, according to HTTP specs.

 o minor
 protected short minor
The minoir version of this message, according to HTTP specs.

 o emitdate
 protected long emitdate
The date at which this message was last emitted.

 o state
 protected ArrayDictionary state
The state dictionary.

 o values
 protected HeaderValue values[]
 o descriptors
 protected static HeaderDescription descriptors[]

Constructors

 o HttpMessage
 public HttpMessage(MimeParser parser)
 o HttpMessage
 public HttpMessage()

Methods

 o registerHeader
 protected static final void registerHeader(String name,
                                            String cls)
 o registerHeader
 protected static final void registerHeader(String name,
                                            String c,
                                            int i)
 o getHeaderValue
 public HeaderValue getHeaderValue(String name,
                                   HeaderValue def)
Get a header value, given its name.

Parameters:
name - The name of the field whose value is to be fetched.
def - The default value if the field is undefined.
 o getHeaderValue
 public final HeaderValue getHeaderValue(String name)
Get a header value by name.

Parameters:
name - The header's name.
Returns:
The value of the header, as a String, or null if undefined.
 o getHeaderValue
 public final HeaderValue getHeaderValue(int idx)
Fast access to header value.

This method provides a very fast access to pre-defined header values. You can use it on all headers that have an access token.

Parameters:
idx - The token of the header to access.
Returns:
An instance of HeaderValue or null if undefined.
 o setHeaderValue
 public void setHeaderValue(String name,
                            HeaderValue value)
Set a header value.

Parameters:
name - The name of the header to define.
value - It's HeaderValue.
 o getHeaderValue
 public HeaderValue getHeaderValue(HeaderDescription d)
Get a header value, keyed by it's header description. This is usefull when enumerating headers, by the mean of enumerateHeaderDescriptions.

Parameters:
d - The header description.
Returns:
A HeaderValue instance, if the header is defined, null otherwise.
 o setHeaderValue
 public void setHeaderValue(HeaderDescription d,
                            HeaderValue v)
Set a header value, keyed by it's header description.

Parameters:
d - The header description.
v - The HeaderValue instance, or null to reset the header value.
 o setHeaderValue
 public final void setHeaderValue(int idx,
                                  HeaderValue value)
Fast write accessor to headers.

This method provides a very fast write access to header values. It can be used with any of the headers that have a pre-defined access token.

Parameters:
idx - The access token of the header's to write to.
value - The new header value.
 o removeHeader
 public void removeHeader(String name)
Remove a header, by name.

Parameters:
name - The name of the header to remove.
 o removeHeader
 public final void removeHeader(int idx)
Remove a header, by address. A fast version of the above.

Parameters:
idx - The index of the header to remove.
 o enumerateHeaderDescriptions
 public Enumeration enumerateHeaderDescriptions(boolean all)
Enumerate all the available headers for that message. This method returns an enumeration of HeaderDescription instances, which you can then use to access most efficiently header values.

Parameters:
all - If true the enumeration will cover all headers (even the ones that are not defined for that message) otherwise, it will cover only defined headers.
Returns:
An enumeration.
 o enumerateHeaderDescriptions
 public Enumeration enumerateHeaderDescriptions()
Enumerate all the headers defined for that message. This method returns an enumeration of HeaderDescription instances, which you can then use to access most efficiently header values.

Returns:
An enumeration.
 o setState
 public void setState(String name,
                      Object value)
State management - Add a piece of state to this request. If the piece of state already exists, it is overriden by the new value.

Parameters:
name - The name of the piece of state to define.
value - It's corresponding value, or null to reset the value.
 o getState
 public Object getState(String name)
State management - Lookup the value of a state on this request.

Parameters:
name - The name of the piece of state to look for.
Returns:
An object, if the piece of state is defined, null otherwise.
 o delState
 public void delState(String name)
State management - Remove a piece of state from this request.

Parameters:
name - The name of the piece of state to remove.
 o hasState
 public boolean hasState(String name)
State management - Is the given state defined for the message ?

Returns:
A boolean true if the state is defined, false otherwise.
 o getClone
 public HttpMessage getClone()
Get a clone of this HTTP message.

Returns:
An HttpMessage, of the class of the message receiver.
 o getValue
 public String getValue(String name)
Get a header field value as a String.

Parameters:
name - The name of the header.
Returns:
A String giving the header value, or null if undefined.
 o getValue
 public String getValue(HeaderDescription d)
Get a header field value as a String.

Parameters:
d - The header description.
Returns:
The String value for the given header, or null if undefined.
 o setValue
 public void setValue(String name,
                      String strval)
Define a new header field.

Parameters:
name - The name of the header to be defined or reset.
value - It's String value, or null to reset the value.
 o hasHeader
 public boolean hasHeader(String name)
Probe this message for a defined header.

Parameters:
name - The name of the header to check.
Returns:
true if the header is defined, false otherwise.
 o hasHeader
 public boolean hasHeader(int idx)
Probe this message for a defined header, fast access !

Parameters:
idx - The index of the well-known header to check.
Returns:
true if the header is defined, false otherwise.
 o notifyHeader
 public void notifyHeader(String name,
                          byte buf[],
                          int off,
                          int len)
MimeHeaderHolder implementation - The MIME parser callback. This method is called if the HttpMessage is created by parsing an input stream. Each time the MIME parser detects a new header field, it calls back this method.

Parameters:
name - The name of the header that has been encountered.
buf - The buffer containing the header value.
off - The offset of the header value in the above buffer.
len - The length of the header value in the above buffer.
 o notifyBeginParsing
 public boolean notifyBeginParsing(MimeParser parser) throws HttpParserException, IOException
MimeHeaderHolder implementation - HTTP message about to be parsed. No further action is required at this point (we do not distinguish between request or reply here). The MIME parsing is to continue normally so we return false.

Returns:
Always false to conotinue the MIME parsing.
 o notifyEndParsing
 public void notifyEndParsing(MimeParser parser) throws HttpParserException, IOException
MimeHeaderHolder implementation - HTTP message parsing done. Nothing special to be done here, return straight.

 o startEmit
 protected void startEmit(OutputStream out,
                          int what) throws IOException
This message is about to be emited. Take any appropriate actions.

 o endEmit
 protected void endEmit(OutputStream out,
                        int what) throws IOException
This message has been emited. Take any appropriate action.

 o emitHeaders
 protected void emitHeaders(OutputStream out,
                            int what) throws IOException
 o dump
 public void dump(OutputStream out)
 o emit
 public void emit(OutputStream out) throws IOException
Emit this message to the given output stream. This methods emits the given message to the stream, after invoking the startEmit method. Once the whole message has been emited, the endEmit method is called back.

Parameters:
out - The output stream to emit the message to.
Throws: IOException
If the message couldn't be emited to the given stream, due to IO errors.
 o emit
 public void emit(OutputStream out,
                  int what) throws IOException
 o setCacheControl
 public void setCacheControl(HttpCacheControl control)
Header accessor - set the cache control associated with the message. This method should not be used in general, it's much more preferable to use the various cache control accessors available.

Parameters:
control - The cache control policy, or null to reset the value.
 o getCacheControl
 public HttpCacheControl getCacheControl()
Header accessor - get the cache control policy.

Returns:
The current cache control policy, or null if undefined.
 o setMaxAge
 public void setMaxAge(int maxage)
Set the max-age value of the associated cache control. This method hides as much as possible, the difference between HTTP/1.1 max-age, and HTTP/1.0 expires headers. It will set only the appropriate one.

Parameters:
maxage - The max-age value, or -1 to reset the value.
 o getMaxAge
 public int getMaxAge()
Get the max-age value for the current cache control.

Returns:
The max age value, as an integer, or -1 if undefined.
 o getNoCache
 public String[] getNoCache()
Get the no-cache directive of the cache control header.

Returns:
A list of token (potentially empty) encoded as an array of String (with 0 length if empty), or null if undefined.
 o setNoCache
 public void setNoCache(String nocache[])
Set the no-cache directive of the cache control header.

Parameters:
nocache - A list of headers name encoded as an array of String (of length possibly 0), or null to reset the value.
 o setNoCache
 public void setNoCache()
Set the no-cache directive globally.

 o addNoCache
 public void addNoCache(String name)
Add the given header name to the no-cache directive.

Parameters:
name - The header name to add there.
 o checkNoStore
 public boolean checkNoStore()
Check the no-store directive of the cache control header.

Returns:
A boolean true if set, false otherwise.
 o setNoStore
 public void setNoStore(boolean onoff)
Set the no-store directive.

Parameters:
onoff - Turn it on or off.
 o checkOnlyIfCached
 public boolean checkOnlyIfCached()
Check the only-if-cached directive.

Returns:
A boolean, true if the directive is set, false otherwise.
 o setOnlyIfCached
 public void setOnlyIfCached(boolean onoff)
Set the only-if-cached directive.

Parameters:
onoff - Turn it on or off.
 o setConnection
 public void setConnection(String tokens[])
Header accessor - set the connection header value.

Parameters:
tokens - The connection tokens as a String array, or null to reset the value.
 o getConnection
 public String[] getConnection()
Header accessor - get the connection header value.

Returns:
The tokens of the connection header, as a String array, or null if undefined.
 o addConnection
 public void addConnection(String name)
Add the given header name to the Connection header.

Parameters:
name - The name of the header to add to the Connection header.
 o hasConnection
 public boolean hasConnection(String tok)
Does the connection header include the given token ?

Returns:
A boolean.
 o setProxyConnection
 public void setProxyConnection(String tokens[])
Header accessor - set the proxy connection header value.

Parameters:
tokens - The connection tokens as a String array, or null to reset the value.
 o addProxyConnection
 public void addProxyConnection(String name)
Add the given header name to the Proxy-Connection header.

Parameters:
name - The name of the header to add to the Proxy-Connection header.
 o getProxyConnection
 public String[] getProxyConnection()
Header accessor - get the proxy connection header value.

Returns:
The tokens of the connection header, as a String array, or null if undefined.
 o hasProxyConnection
 public boolean hasProxyConnection(String tok)
Does the proxy connection header defines the given token.

Parameters:
tok - The token to check for.
Returns:
A boolean.
 o setDate
 public void setDate(long date)
Header accessor - set the date of this message.

Parameters:
date - The date of the message, following Java runtime conventions (number of milliseconds since epoch), or -1 to reset the value.
 o getDate
 public long getDate()
Header accessor - get the date of this message.

Returns:
A long giving the date of this message, following the Java runtime convention (milliseconds since epoch), or -1 if undefined.
 o setPragma
 public void setPragma(String tokens[])
Header accessor - set the pragmas applicable to this message.

Parameters:
tokens - The pragma tokens as a String array, or null to reset the value.
 o getPragma
 public String[] getPragma()
Header accessor - get the pragmas applicable to this message.

Returns:
The pragma tokens applicable to this message, encoded as a String array, or null if undefined.
 o hasPragma
 public boolean hasPragma(String pragma)
Header accessor - Check for a given pragma.

Parameters:
pragma - The pragma to check for.
Returns:
A boolean true if this pragma is set, false otherwise.
 o addPragma
 public void addPragma(String name)
Add the given directive to the Pragma header.

Parameters:
name - The name of the directive to add to the Pragma header.
 o setTransferEncoding
 public void setTransferEncoding(String tokens[])
Header accessor - set the transfer encoding for this message. This just sets the transfer encoding, it is up to the rest of the application to make sure that the encoding is actually applied at emiting time.

Parameters:
tokens - The transfer encoding tokens as a String array, or null to reset the value.
 o getTransferEncoding
 public String[] getTransferEncoding()
Header accessor - get the transfer encoding applying to this message.

Returns:
The list of encoding tokens, as a String array, or null if undefined.
 o hasTransferEncoding
 public boolean hasTransferEncoding(String encoding)
Header accessor - Check for a given transfer encoding.

Parameters:
encoding - The pragma to check for.
Returns:
A boolean true if this encoding is set, false otherwise.
 o setUpgrade
 public void setUpgrade(String products[])
Header accessor - set the upgrade header of this message.

Parameters:
products - An array of products you want this message to carry or null to reset the value.
 o getUpgrade
 public String[] getUpgrade()
Header accessor - get the upgrade header of this message.

Returns:
A list of products, encoded as an array of String or null if undefined.
 o setVia
 public void setVia(String vias[])
Header accessor - set the Via header of this message.

Parameters:
vias - The hops to be placed in the Via header, or null to reset the value.
 o getVia
 public String[] getVia()
Header accessor - get the via header of this message.

Returns:
A Via array describing each hop of the message, or null if undefined.
 o addVia
 public void addVia(String via)
Add a via clause to the via header.

Parameters:
via - The new via clause.
 o getProtocol
 public HttpBag getProtocol()
Get the set of protocol extensions that have been aplpied to that that message.

Returns:
A bag containing the description of the protocol extensions applied to that message, or null.
 o setProtocol
 public void setProtocol(HttpBag bag)
Set the protocol extensions applied to that message.

Parameters:
protocols - A bag instance, describing the protocol extensions applied to the message, or null to reset previous value.
 o getProtocolRequest
 public HttpBag getProtocolRequest()
Get the set of protocol extensions requested by this message.

Returns:
A bag containing the description of the protocol extensions requested by this message, or null.
 o setProtocolRequest
 public void setProtocolRequest(HttpBag bag)
Set the protocol extensions required by this message.

Parameters:
protocols - A bag instance, describing the protocol extensions required by the message, or null to reset previous value.
 o getProtocolInfo
 public HttpBag getProtocolInfo()
Get the protocol extensions informations carried by this message.

Returns:
A bag containing the description of the protocol extensions informations carried by that message, or null.
 o setProtocolInfo
 public void setProtocolInfo(HttpBag bag)
Attach protocol extensions informations to that message.

Parameters:
protocols - A bag instance, describing the protocol extensions informations to attach to the message, or null to reset previous value.
 o getProtocolQuery
 public HttpBag getProtocolQuery()
Get the set of protocol extensions that are queried through this message.

Returns:
A bag containing the description of the protocol extensions queried by that message, or null.
 o setProtocolQuery
 public void setProtocolQuery(HttpBag bag)
Set the protocol extensions queried by that message.

Parameters:
protocols - A bag instance, describing the protocol extensions queried by the message, or null to reset previous value.
 o getSetCookie
 public HttpSetCookieList getSetCookie()
Get the value of the SetCookie header.

Returns:
AN HttpSetCookie instance, or null if undefined.
 o setSetCookie
 public void setSetCookie(HttpSetCookieList setcookie)
Set the value of the Set-Cookie header.

Parameters:
setcookies - The HttpSetCookie value.
 o getCookie
 public HttpCookieList getCookie()
Get the cookies attached to that message.

Returns:
An instance of HttpCookie holding the list of available cookies, or null if undefined.
 o setCookie
 public void setCookie(HttpCookieList cookie)
Set the cookies attached to this message.

Parameters:
cookies - The HttpCookie instance describing the cookies, or null to reset value.
 o getVersion
 public String getVersion()
Get the String identifying the HTTP version used for this message.

Returns:
A String identifying the protocol version.
 o getMajorVersion
 public short getMajorVersion()
Get the major version number of this message. This method returns the major version that the caller should use to drive message processing. It may not match the version number actually emitted on the wire, which is computed by the API itself.

Returns:
A ninteger giving the major version number.
 o getMinorVersion
 public short getMinorVersion()
Get the minor version number of this message. This method returns the minor version that the caller should use to drive message processing. It may not match the minor version number emitted on the wire, which is computed by the API itself.

Returns:
An integer giving the minor version number.
 o getEmitDate
 public long getEmitDate()
Get the date at which this message was last emitted, if ever it was.

Returns:
The date, in milliseconds since Java epoch at which this message was emitted, or -1 if the message was never emitted.

All Packages  Class Hierarchy  This Package  Previous  Next  Index