|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.w3c.www.http.HttpMessage
public class HttpMessage
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.
Field Summary | |
---|---|
protected static HeaderDescription[] |
descriptors
|
static int |
EMIT_ALL
|
static int |
EMIT_BODY
|
static int |
EMIT_FOOTERS
|
static int |
EMIT_HEADERS
|
protected long |
emitdate
The date at which this message was last emitted. |
protected static java.util.Hashtable |
factory
The header value factory. |
static int |
H_CACHE_CONTROL
|
static int |
H_CMAN_EXT
|
static int |
H_CONNECTION
|
static int |
H_COOKIE
|
static int |
H_COPT_EXT
|
static int |
H_DATE
|
static int |
H_MAN_EXT
|
static int |
H_OPT_EXT
|
static int |
H_PRAGMA
|
static int |
H_PROTOCOL
|
static int |
H_PROTOCOL_INFO
|
static int |
H_PROTOCOL_QUERY
|
static int |
H_PROTOCOL_REQUEST
|
static int |
H_PROXY_CONNECTION
|
static int |
H_SET_COOKIE
|
static int |
H_TRAILER
|
static int |
H_TRANSFER_ENCODING
|
static int |
H_UPGRADE
|
static int |
H_VIA
|
protected java.util.Dictionary |
headers
The header value repository. |
protected short |
major
The major version of this message, according to HTTP specs. |
static int |
MAX_HEADERS
|
protected short |
minor
The minoir version of this message, according to HTTP specs. |
protected ArrayDictionary |
state
The state dictionary. |
protected HeaderValue[] |
values
|
Constructor Summary | |
---|---|
HttpMessage()
|
|
HttpMessage(MimeParser parser)
|
Method Summary | |
---|---|
void |
addConnection(java.lang.String name)
Add the given header name to the Connection header. |
void |
addNoCache(java.lang.String name)
Add the given header name to the no-cache directive. |
void |
addPragma(java.lang.String name)
Add the given directive to the Pragma header. |
void |
addProxyConnection(java.lang.String name)
Add the given header name to the Proxy-Connection header. |
void |
addTransferEncoding(java.lang.String name)
Add an encoding token to the given reply stream (ie the body). |
void |
addVia(java.lang.String via)
Add a via clause to the via header. |
boolean |
checkNoStore()
Check the no-store directive of the cache control header. |
boolean |
checkOnlyIfCached()
Check the only-if-cached directive. |
void |
delState(java.lang.String name)
State management - Remove a piece of state from this request. |
void |
dump(java.io.OutputStream out)
|
void |
emit(java.io.OutputStream out)
Emit this message to the given output stream. |
void |
emit(java.io.OutputStream out,
int what)
|
protected void |
emitHeaders(java.io.OutputStream out,
int what)
Emit the headers. |
protected void |
endEmit(java.io.OutputStream out,
int what)
This message has been emited. |
java.util.Enumeration |
enumerateHeaderDescriptions()
Enumerate all the headers defined for that message. |
java.util.Enumeration |
enumerateHeaderDescriptions(boolean all)
Enumerate all the available headers for that message. |
protected java.lang.String |
generateExtNamespace()
get a new namespace. |
HttpCacheControl |
getCacheControl()
Header accessor - get the cache control policy. |
HttpMessage |
getClone()
Get a clone of this HTTP message. |
java.lang.String |
getCManExtHeader(java.lang.String ext,
java.lang.String header)
get the String value of the given header relative to the given Extension. |
java.lang.String[] |
getConnection()
Header accessor - get the connection header value. |
HttpCookieList |
getCookie()
Get the cookies attached to that message. |
java.lang.String |
getCOptExtHeader(java.lang.String ext,
java.lang.String header)
get the String value of the given header relative to the given Extension. |
long |
getDate()
Header accessor - get the date of this message. |
HttpMessage |
getDeeperClone()
Get a clone of this HTTP message. |
long |
getEmitDate()
Get the date at which this message was last emitted, if ever it was. |
java.util.Dictionary |
getExtensionHeaders(HttpExt ext)
Get the headers relative to the given Http Extension declaration. |
java.lang.String |
getExtHeader(java.lang.String ext,
java.lang.String header)
get the String value of the given header relative to the given Extension. |
HttpExtList |
getExtList(java.lang.String id)
Get an Http Extension Listfrom the following list: Mandatory (End-to-End) Extensions Mandatory (Hop-by-Hop) Extensions Optionnal (End-to-End) Extensions Optionnal (hop-by-Hop) Extensions |
HeaderValue |
getHeaderValue(HeaderDescription d)
Get a header value, keyed by it's header description. |
HeaderValue |
getHeaderValue(int idx)
Fast access to header value. |
HeaderValue |
getHeaderValue(java.lang.String name)
Get a header value by name. |
HeaderValue |
getHeaderValue(java.lang.String name,
HeaderValue def)
Get a header value, given its name. |
HttpExtList |
getHttpCManExtDecl()
Get The Mandatory (Hop-by-Hop) Extension declaration list. |
HttpExtList |
getHttpCOptExtDecl()
Get The Optionnal (Hop-by-Hop) Extension declaration list. |
HttpExtList |
getHttpManExtDecl()
Get The Mandatory (End-to-End) Extension declaration list. |
HttpExtList |
getHttpOptExtDecl()
Get The Optionnal (End-to-End) Extension declaration list. |
short |
getMajorVersion()
Get the major version number of this message. |
java.lang.String |
getManExtHeader(java.lang.String ext,
java.lang.String header)
get the String value of the given header relative to the given Extension. |
int |
getMaxAge()
Get the max-age value for the current cache control. |
short |
getMinorVersion()
Get the minor version number of this message. |
java.lang.String[] |
getNoCache()
Get the no-cache directive of the cache control header. |
java.lang.String |
getOptExtHeader(java.lang.String ext,
java.lang.String header)
get the String value of the given header relative to the given Extension. |
java.lang.String[] |
getPragma()
Header accessor - get the pragmas applicable to this message. |
HttpBag |
getProtocol()
Get the set of protocol extensions that have been applied to that that message. |
HttpBag |
getProtocolInfo()
Get the protocol extensions informations carried by this message. |
HttpBag |
getProtocolQuery()
Get the set of protocol extensions that are queried through this message. |
HttpBag |
getProtocolRequest()
Get the set of protocol extensions requested by this message. |
java.lang.String[] |
getProxyConnection()
Header accessor - get the proxy connection header value. |
HttpSetCookieList |
getSetCookie()
Get the value of the SetCookie header. |
int |
getSMaxAge()
Get the s-maxage value for the current cache control. |
java.lang.Object |
getState(java.lang.String name)
State management - Lookup the value of a state on this request. |
java.util.Enumeration |
getStateNames()
Get an enumeration of the states names. |
java.lang.String[] |
getTrailer()
Get this message trailer |
java.lang.String[] |
getTransferEncoding()
Header accessor - get the transfer encoding applying to this message. |
java.lang.String[] |
getUpgrade()
Header accessor - get the upgrade header of this message. |
java.lang.String |
getValue(HeaderDescription d)
Get a header field value as a String. |
java.lang.String |
getValue(java.lang.String name)
Get a header field value as a String. |
java.lang.String |
getVersion()
Get the String identifying the HTTP version used for this message. |
java.lang.String[] |
getVia()
Header accessor - get the via header of this message. |
boolean |
hasConnection(java.lang.String tok)
Does the connection header include the given token ? |
boolean |
hasHeader(int idx)
Probe this message for a defined header, fast access ! |
boolean |
hasHeader(java.lang.String name)
Probe this message for a defined header. |
boolean |
hasPragma(java.lang.String pragma)
Header accessor - Check for a given pragma. |
boolean |
hasProxyConnection(java.lang.String tok)
Does the proxy connection header defines the given token. |
boolean |
hasState(java.lang.String name)
State management - Is the given state defined for the message ? |
boolean |
hasTransferEncoding(java.lang.String encoding)
Header accessor - Check for a given transfer encoding. |
boolean |
notifyBeginParsing(MimeParser parser)
MimeHeaderHolder implementation - HTTP message about to be parsed. |
void |
notifyEndParsing(MimeParser parser)
MimeHeaderHolder implementation - HTTP message parsing done. |
void |
notifyHeader(java.lang.String name,
byte[] buf,
int off,
int len)
MimeHeaderHolder implementation - The MIME parser callback. |
static void |
registerExtHeader(java.lang.String name,
java.lang.String cls)
|
protected static void |
registerHeader(java.lang.String name,
java.lang.String cls)
|
protected static void |
registerHeader(java.lang.String name,
java.lang.String c,
int i)
|
void |
removeHeader(int idx)
Remove a header, by address. |
void |
removeHeader(java.lang.String name)
Remove a header, by name. |
void |
setCacheControl(HttpCacheControl control)
Header accessor - set the cache control associated with the message. |
void |
setConnection(java.lang.String[] tokens)
Header accessor - set the connection header value. |
void |
setCookie(HttpCookieList cookie)
Set the cookies attached to this message. |
void |
setDate(long date)
Header accessor - set the date of this message. |
void |
setEnd2EndExtensionAcknowledgmentHeader()
|
void |
setExtensionHeader(HttpExt ext,
java.lang.String name,
java.lang.String value)
Set an extension header relative to the given extension declaration. |
void |
setHeaderValue(HeaderDescription d,
HeaderValue v)
Set a header value, keyed by it's header description. |
void |
setHeaderValue(int idx,
HeaderValue value)
Fast write accessor to headers. |
void |
setHeaderValue(java.lang.String name,
HeaderValue value)
Set a header value. |
void |
setHopByHopExtensionAcknowledgmentHeader()
|
void |
setHttpCManExtDecl(HttpExtList exts)
Set The Mandatory (Hop-by-Hop) Extension declaration list. |
void |
setHttpCOptExtDecl(HttpExtList exts)
Set The Optional (Hop-by-Hop) Extension declaration list. |
void |
setHttpExtDecl(HttpExtList exts)
Set the Extension declaration. |
void |
setHttpManExtDecl(HttpExtList exts)
Set The Mandatory (End-to-End) Extension declaration list. |
void |
setHttpOptExtDecl(HttpExtList exts)
Set The Optional (End-to-End) Extension declaration list. |
void |
setMaxAge(int maxage)
Set the max-age value of the associated cache control. |
protected void |
setNamespaces(HttpExtList extl)
|
void |
setNoCache()
Set the no-cache directive globally. |
void |
setNoCache(java.lang.String[] nocache)
Set the no-cache directive of the cache control header. |
void |
setNoStore(boolean onoff)
Set the no-store directive. |
void |
setOnlyIfCached(boolean onoff)
Set the only-if-cached directive. |
void |
setPragma(java.lang.String[] tokens)
Header accessor - set the pragmas applicable to this message. |
void |
setProtocol(HttpBag bag)
Set the protocol extensions applied to that message. |
void |
setProtocolInfo(HttpBag bag)
Attach protocol extensions informations to that message. |
void |
setProtocolQuery(HttpBag bag)
Set the protocol extensions queried by that message. |
void |
setProtocolRequest(HttpBag bag)
Set the protocol extensions required by this message. |
void |
setProxyConnection(java.lang.String[] tokens)
Header accessor - set the proxy connection header value. |
void |
setSetCookie(HttpSetCookieList setcookie)
Set the value of the Set-Cookie header. |
void |
setSMaxAge(int smaxage)
Set the s-maxage value of the associated cache control. |
void |
setState(java.lang.String name,
java.lang.Object value)
State management - Add a piece of state to this request. |
void |
setTrailer(java.lang.String[] trailers)
Set this message trailer |
void |
setTransferEncoding(java.lang.String[] tokens)
Header accessor - set the transfer encoding for this message. |
void |
setUpgrade(java.lang.String[] products)
Header accessor - set the upgrade header of this message. |
void |
setValue(java.lang.String name,
java.lang.String strval)
Define a new header field. |
void |
setVia(java.lang.String[] vias)
Header accessor - set the Via header of this message. |
protected void |
startEmit(java.io.OutputStream out,
int what)
This message is about to be emited. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int EMIT_HEADERS
public static final int EMIT_BODY
public static final int EMIT_FOOTERS
public static final int EMIT_ALL
public static int H_CACHE_CONTROL
public static int H_CONNECTION
public static int H_PROXY_CONNECTION
public static int H_DATE
public static int H_PRAGMA
public static int H_TRANSFER_ENCODING
public static int H_UPGRADE
public static int H_VIA
public static int H_PROTOCOL
public static int H_PROTOCOL_REQUEST
public static int H_PROTOCOL_INFO
public static int H_PROTOCOL_QUERY
public static int H_SET_COOKIE
public static int H_COOKIE
public static int H_TRAILER
public static int H_MAN_EXT
public static int H_OPT_EXT
public static int H_CMAN_EXT
public static int H_COPT_EXT
public static int MAX_HEADERS
protected static java.util.Hashtable factory
protected java.util.Dictionary headers
protected short major
protected short minor
protected long emitdate
protected ArrayDictionary state
protected HeaderValue[] values
protected static HeaderDescription[] descriptors
Constructor Detail |
---|
public HttpMessage(MimeParser parser)
public HttpMessage()
Method Detail |
---|
protected static final void registerHeader(java.lang.String name, java.lang.String cls)
protected static final void registerHeader(java.lang.String name, java.lang.String c, int i)
public HeaderValue getHeaderValue(java.lang.String name, HeaderValue def)
name
- The name of the field whose value is to be fetched.def
- The default value if the field is undefined.public final HeaderValue getHeaderValue(java.lang.String name)
name
- The header's name.
public final HeaderValue getHeaderValue(int idx)
This method provides a very fast access to pre-defined header values. You can use it on all headers that have an access token.
idx
- The token of the header to access.
HeaderValue
or null
if undefined.public void setHeaderValue(java.lang.String name, HeaderValue value)
name
- The name of the header to define.value
- It's HeaderValue.public HeaderValue getHeaderValue(HeaderDescription d)
enumerateHeaderDescriptions
.
d
- The header description.
public void setHeaderValue(HeaderDescription d, HeaderValue v)
d
- The header description.v
- The HeaderValue instance, or null to
reset the header value.public final void setHeaderValue(int idx, HeaderValue value)
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.
idx
- The access token of the header's to write to.value
- The new header value.public void removeHeader(java.lang.String name)
name
- The name of the header to remove.public final void removeHeader(int idx)
idx
- The index of the header to remove.public java.util.Enumeration enumerateHeaderDescriptions(boolean all)
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.
public java.util.Enumeration enumerateHeaderDescriptions()
public void setState(java.lang.String name, java.lang.Object value)
name
- The name of the piece of state to define.value
- It's corresponding value, or null to
reset the value.public java.lang.Object getState(java.lang.String name)
name
- The name of the piece of state to look for.
public void delState(java.lang.String name)
name
- The name of the piece of state to remove.public boolean hasState(java.lang.String name)
public java.util.Enumeration getStateNames()
public HttpMessage getClone()
public HttpMessage getDeeperClone()
public java.lang.String getValue(java.lang.String name)
name
- The name of the header.
public java.lang.String getValue(HeaderDescription d)
d
- The header description.
public void setValue(java.lang.String name, java.lang.String strval)
name
- The name of the header to be defined or reset.value
- It's String value, or null to reset
the value.public boolean hasHeader(java.lang.String name)
name
- The name of the header to check.
public boolean hasHeader(int idx)
idx
- The index of the well-known header to check.
public void notifyHeader(java.lang.String name, byte[] buf, int off, int len)
notifyHeader
in interface MimeHeaderHolder
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.public boolean notifyBeginParsing(MimeParser parser) throws HttpParserException, java.io.IOException
notifyBeginParsing
in interface MimeHeaderHolder
parser
- The Mime parser.
HttpParserException
- if parsing failed.
java.io.IOException
- if an IO error occurs.public void notifyEndParsing(MimeParser parser) throws HttpParserException, java.io.IOException
notifyEndParsing
in interface MimeHeaderHolder
parser
- The Mime parser.
HttpParserException
- if parsing failed.
java.io.IOException
- if an IO error occurs.protected void startEmit(java.io.OutputStream out, int what) throws java.io.IOException
java.io.IOException
- if an IO error occurs.protected void endEmit(java.io.OutputStream out, int what) throws java.io.IOException
java.io.IOException
- if an IO error occurs.protected void emitHeaders(java.io.OutputStream out, int what) throws java.io.IOException
java.io.IOException
- if an IO error occurs.public void dump(java.io.OutputStream out)
public void emit(java.io.OutputStream out) throws java.io.IOException
startEmit
method. Once the whole message has been
emited, the endEmit
method is called back.
out
- The output stream to emit the message to.
java.io.IOException
- If the message couldn't be emited to the
given stream, due to IO errors.public void emit(java.io.OutputStream out, int what) throws java.io.IOException
out
- The output stream to emit the message to.what
- (fixme doc)
java.io.IOException
- If the message couldn't be emited to the
given stream, due to IO errors.public void setCacheControl(HttpCacheControl control)
control
- The cache control policy, or null
to reset the value.public HttpCacheControl getCacheControl()
public void setMaxAge(int maxage)
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.
maxage
- The max-age value, or -1 to reset the
value.public int getMaxAge()
max-age
value for the current cache control.
public void setSMaxAge(int smaxage)
s-maxage
value of the associated cache control.
Set the s-maxage value on an HTTP/1.1 reply
maxage
- The max-age value in seconds, or -1
to reset the value.public int getSMaxAge()
s-maxage
value for the current cache control.
public java.lang.String[] getNoCache()
no-cache
directive of the cache control header.
public void setNoCache(java.lang.String[] nocache)
no-cache
directive of the cache control header.
nocache
- A list of headers name encoded as an array of String
(of length possibly 0), or null
to reset the value.public void setNoCache()
no-cache
directive globally.
public void addNoCache(java.lang.String name)
no-cache
directive.
name
- The header name to add there.public boolean checkNoStore()
no-store
directive of the cache control header.
public void setNoStore(boolean onoff)
no-store
directive.
onoff
- Turn it on or off.public boolean checkOnlyIfCached()
only-if-cached
directive.
public void setOnlyIfCached(boolean onoff)
only-if-cached
directive.
onoff
- Turn it on or off.public void setConnection(java.lang.String[] tokens)
tokens
- The connection tokens as a String array, or null
to reset the value.public java.lang.String[] getConnection()
public void addConnection(java.lang.String name)
Connection
header.
name
- The name of the header to add to the Connection
header.public boolean hasConnection(java.lang.String tok)
public void setProxyConnection(java.lang.String[] tokens)
tokens
- The connection tokens as a String array, or
null to reset the value.public void addProxyConnection(java.lang.String name)
Proxy-Connection
header.
name
- The name of the header to add to the
Proxy-Connection
header.public java.lang.String[] getProxyConnection()
public boolean hasProxyConnection(java.lang.String tok)
tok
- The token to check for.
public void setDate(long date)
date
- The date of the message, following Java runtime conventions
(number of milliseconds since epoch), or -1 to
reset the value.public long getDate()
public void setPragma(java.lang.String[] tokens)
tokens
- The pragma tokens as a String array, or null
to reset the value.public java.lang.String[] getPragma()
public boolean hasPragma(java.lang.String pragma)
pragma
- The pragma to check for.
public void addPragma(java.lang.String name)
Pragma
header.
name
- The name of the directive to add to the Pragma
header.public void setTransferEncoding(java.lang.String[] tokens)
tokens
- The transfer encoding tokens as a String array, or
null to reset the value.public void addTransferEncoding(java.lang.String name)
name
- The name of the encoding to add.public java.lang.String[] getTransferEncoding()
public boolean hasTransferEncoding(java.lang.String encoding)
encoding
- The pragma to check for.
public void setUpgrade(java.lang.String[] products)
products
- An array of products you want this message to carry
or null to reset the value.public java.lang.String[] getUpgrade()
public void setVia(java.lang.String[] vias)
vias
- The hops to be placed in the Via
header, or
null to reset the value.public java.lang.String[] getVia()
public void addVia(java.lang.String via)
via
- The new via clause.public HttpBag getProtocol()
public void setProtocol(HttpBag bag)
protocols
- A bag instance, describing the protocol extensions
applied to the message, or null to reset previous
value.public HttpBag getProtocolRequest()
public void setProtocolRequest(HttpBag bag)
protocols
- A bag instance, describing the protocol extensions
required by the message, or null to reset previous
value.public HttpBag getProtocolInfo()
public void setProtocolInfo(HttpBag bag)
protocols
- A bag instance, describing the protocol extensions
informations to attach to the message, or null to
reset previous value.public HttpBag getProtocolQuery()
public void setProtocolQuery(HttpBag bag)
protocols
- A bag instance, describing the protocol extensions
queried by the message, or null to reset previous
value.public java.lang.String[] getTrailer()
public void setTrailer(java.lang.String[] trailers)
encodings
- A list of encoding tokens, encoded as a String array
or null to reset the value.public HttpSetCookieList getSetCookie()
public void setSetCookie(HttpSetCookieList setcookie)
setcookies
- The HttpSetCookie value.public HttpCookieList getCookie()
public void setCookie(HttpCookieList cookie)
cookies
- The HttpCookie instance describing the cookies, or
null to reset value.public java.lang.String getVersion()
public short getMajorVersion()
public short getMinorVersion()
public long getEmitDate()
public HttpExtList getExtList(java.lang.String id)
ext
- the Extension id
public java.lang.String getExtHeader(java.lang.String ext, java.lang.String header)
ext
- the extensionheader
- the extension header
public java.lang.String getManExtHeader(java.lang.String ext, java.lang.String header)
ext
- the extensionheader
- the extension header
public java.lang.String getOptExtHeader(java.lang.String ext, java.lang.String header)
ext
- the extensionheader
- the extension header
public java.lang.String getCManExtHeader(java.lang.String ext, java.lang.String header)
ext
- the extensionheader
- the extension header
public java.lang.String getCOptExtHeader(java.lang.String ext, java.lang.String header)
ext
- the extensionheader
- the extension header
public HttpExtList getHttpManExtDecl()
public void setHttpManExtDecl(HttpExtList exts)
exts
- the extension declaration list.public HttpExtList getHttpCManExtDecl()
public void setHttpExtDecl(HttpExtList exts)
exts
- the extension declaration list.public void setHttpCManExtDecl(HttpExtList exts)
exts
- the extension declaration list.public HttpExtList getHttpOptExtDecl()
public void setHttpOptExtDecl(HttpExtList exts)
exts
- the extension declaration list.public HttpExtList getHttpCOptExtDecl()
public void setHttpCOptExtDecl(HttpExtList exts)
exts
- the extension declaration list.protected void setNamespaces(HttpExtList extl)
public java.util.Dictionary getExtensionHeaders(HttpExt ext)
ext
- the HttpExt
public void setExtensionHeader(HttpExt ext, java.lang.String name, java.lang.String value)
ext
- The extension declarationname
- the header namevalue
- the header valueprotected java.lang.String generateExtNamespace()
public void setEnd2EndExtensionAcknowledgmentHeader()
public void setHopByHopExtensionAcknowledgmentHeader()
public static final void registerExtHeader(java.lang.String name, java.lang.String cls)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |