| java.lang.Object org.apache.tomcat.util.http.MimeHeaders
MimeHeaders | public class MimeHeaders (Code) | | Memory-efficient repository for Mime Headers. When the object is recycled, it
will keep the allocated headers[] and all the MimeHeaderField - no GC is generated.
For input headers it is possible to use the MessageByte for Fileds - so no GC
will be generated.
The only garbage is generated when using the String for header names/values -
this can't be avoided when the servlet calls header methods, but is easy
to avoid inside tomcat. The goal is to use _only_ MessageByte-based Fields,
and reduce to 0 the memory overhead of tomcat.
TODO:
XXX one-buffer parsing - for http ( other protocols don't need that )
XXX remove unused methods
XXX External enumerations, with 0 GC.
XXX use HeaderName ID
author: dac@eng.sun.com author: James Todd [gonzo@eng.sun.com] author: Costin Manolache author: kevin seguin |
Constructor Summary | |
public | MimeHeaders() Creates a new MimeHeaders object using a default buffer size. |
DEFAULT_HEADER_SIZE | final public static int DEFAULT_HEADER_SIZE(Code) | | Initial size - should be == average number of headers per request
XXX make it configurable ( fine-tuning of web-apps )
|
MimeHeaders | public MimeHeaders()(Code) | | Creates a new MimeHeaders object using a default buffer size.
|
addValue | public MessageBytes addValue(String name)(Code) | | Create a new named header , return the MessageBytes
container for the new value
|
addValue | public MessageBytes addValue(byte b, int startN, int len)(Code) | | Create a new named header using un-translated byte[].
The conversion to chars can be delayed until
encoding is known.
|
addValue | public MessageBytes addValue(char c, int startN, int len)(Code) | | Create a new named header using translated char[].
|
clear | public void clear()(Code) | | Clears all header fields.
|
findHeader | public int findHeader(String name, int starting)(Code) | | Find the index of a header with the given name.
|
getName | public MessageBytes getName(int n)(Code) | | Returns the Nth header name, or null if there is no such header.
This may be used to iterate through all header fields.
|
getValue | public MessageBytes getValue(int n)(Code) | | Returns the Nth header value, or null if there is no such header.
This may be used to iterate through all header fields.
|
getValue | public MessageBytes getValue(String name)(Code) | | Finds and returns a header field with the given name. If no such
field exists, null is returned. If more than one such field is
in the header, an arbitrary one is returned.
|
names | public Enumeration names()(Code) | | Returns an enumeration of strings representing the header field names.
Field names may appear multiple times in this enumeration, indicating
that multiple fields with that name exist in this header.
|
recycle | public void recycle()(Code) | | Clears all header fields.
|
removeHeader | public void removeHeader(String name)(Code) | | Removes a header field with the specified name. Does nothing
if such a field could not be found.
Parameters: name - the name of the header field to be removed |
setValue | public MessageBytes setValue(String name)(Code) | | Allow "set" operations -
return a MessageBytes container for the
header value ( existing header or new
if this .
|
size | public int size()(Code) | | Returns the current number of header fields.
|
toString | public String toString()(Code) | | EXPENSIVE!!! only for debugging.
|
|
|