All Packages Class Hierarchy This Package Previous Next Index
Class sun.servlet.http.MimeHeaders
java.lang.Object
|
+----sun.servlet.http.MimeHeaders
- public class MimeHeaders
- extends Object
This class is used to contain the MIME headers for an HTTP request.
It contains methods for setting and getting individual headers, as
well as reading and writing headers from and to streams.
-
buf
- The byte buffer to use when parsing headers.
-
count
- The current number of headers.
-
headers
- The header fields.
-
MimeHeaders()
- Creates a new MimeHeaders object using a default buffer size.
-
MimeHeaders(int)
- Creates a new MimeHeaders object using the specified buffer size.
-
clear()
- Clears all header fields.
-
containsHeader(String)
- Returns true if the specified header is contained in the list
of headers otherwise returns false.
-
dump(PrintStream)
- Dumps current headers to specified PrintStream for debugging.
-
find(String)
- Finds and returns the request header matching name.
-
getDateHeader(String)
- Returns the date value of the specified header field.
-
getHeader(int)
- Returns the value of the nth header field where n >= 0.
-
getHeader(String)
- Returns the string value of the specified header field.
-
getHeaderName(int)
- Returns the name of the nth header field where n >= 0.
-
getIntHeader(String)
- Returns the integer value of the specified header field.
-
names()
- Returns an enumeration of strings representing the header field names.
-
putDateHeader(String)
- Sets a header field date value to the current time.
-
putDateHeader(String, long)
- Sets a header field date value to the specified time.
-
putHeader()
- Creates a new header field.
-
putHeader(String)
- Searches for a header field corresponding to the specified name and
creates a new one if not found.
-
putHeader(String, String)
- Sets a header field value to the specified string.
-
putIntHeader(String, int)
- Sets a header field value to the specified integer.
-
read(ServletInputStream)
- Reads header fields from the specified servlet input stream until
a blank line is encountered.
-
removeHeader(String)
- Removes the specified header field.
-
size()
- Returns the current number of header fields.
-
toString()
- Returns a lengthly string representation of the current header fields.
-
write(ServletOutputStream)
- Writes out header fields to the specified servlet output stream.
headers
protected MimeHeaderField headers[]
- The header fields.
count
protected int count
- The current number of headers.
buf
protected byte buf[]
- The byte buffer to use when parsing headers.
MimeHeaders
public MimeHeaders(int len)
- Creates a new MimeHeaders object using the specified buffer size.
- Parameters:
- len - the buffer size for parsing headers
MimeHeaders
public MimeHeaders()
- Creates a new MimeHeaders object using a default buffer size.
clear
public void clear()
- Clears all header fields.
size
public int size()
- Returns the current number of header fields.
names
public Enumeration names()
- Returns an enumeration of strings representing the header field names.
putHeader
public void putHeader(String name,
String s)
- Sets a header field value to the specified string.
- Parameters:
- name - the header name
- s - the header field string value
putIntHeader
public void putIntHeader(String name,
int i)
- Sets a header field value to the specified integer.
- Parameters:
- name - the header name
- i - the header field integer value
putDateHeader
public void putDateHeader(String name,
long t)
- Sets a header field date value to the specified time.
- Parameters:
- name - the header name
- t - the time in number of milliseconds since the epoch
putDateHeader
public void putDateHeader(String name)
- Sets a header field date value to the current time.
- Parameters:
- name - the header name
getHeader
public String getHeader(String name)
- Returns the string value of the specified header field.
- Parameters:
- name - the header field name
- Returns:
- the string value of the header, or null if not found
getIntHeader
public int getIntHeader(String name) throws NumberFormatException
- Returns the integer value of the specified header field.
- Parameters:
- name - the header field name
- Returns:
- the integer value of the header field, or -1 if the header
was not found
- Throws: NumberFormatException
- if the integer format was invalid
getDateHeader
public long getDateHeader(String name) throws IllegalArgumentException
- Returns the date value of the specified header field.
- Parameters:
- name - the header field name
- Returns:
- the date value of the header field in number of milliseconds
since the epoch, or -1 if the header was not found
- Throws: IllegalArgumentException
- if the date format was invalid
getHeaderName
public String getHeaderName(int n)
- Returns the name of the nth header field where n >= 0. Returns null
if there were fewer than (n + 1) fields. This can be used to iterate
through all the headers in the message.
getHeader
public String getHeader(int n)
- Returns the value of the nth header field where n >= 0. Returns null
if there were fewer than (n + 1) fields. This can be used in conjunction
with getHeaderName to iterate through all the headers in the message.
find
protected MimeHeaderField find(String name)
- Finds and returns the request header matching name.
removeHeader
public void removeHeader(String name)
- Removes the specified header field. Does nothing if the header could
not be found.
- Parameters:
- name - the name of the header field to be removed
containsHeader
public boolean containsHeader(String name)
- Returns true if the specified header is contained in the list
of headers otherwise returns false.
- Parameters:
- name - the header name
read
public void read(ServletInputStream in) throws IOException
- Reads header fields from the specified servlet input stream until
a blank line is encountered.
- Parameters:
- in - the servlet input stream
- Throws: IllegalArgumentException
- if the header format was invalid
- Throws: IOException
- if an I/O error has occurred
write
public void write(ServletOutputStream out) throws IOException
- Writes out header fields to the specified servlet output stream.
- Parameters:
- out - the servlet output stream
- Throws: IOException
- if an I/O error has occurred
putHeader
protected MimeHeaderField putHeader(String name)
- Searches for a header field corresponding to the specified name and
creates a new one if not found.
- Parameters:
- name - the header field name
putHeader
protected MimeHeaderField putHeader()
- Creates a new header field.
toString
public String toString()
- Returns a lengthly string representation of the current header fields.
- Overrides:
- toString in class Object
dump
public void dump(PrintStream out)
- Dumps current headers to specified PrintStream for debugging.
All Packages Class Hierarchy This Package Previous Next Index