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.


Variable Index

 o buf
The byte buffer to use when parsing headers.
 o count
The current number of headers.
 o headers
The header fields.

Constructor Index

 o MimeHeaders()
Creates a new MimeHeaders object using a default buffer size.
 o MimeHeaders(int)
Creates a new MimeHeaders object using the specified buffer size.

Method Index

 o clear()
Clears all header fields.
 o containsHeader(String)
Returns true if the specified header is contained in the list of headers otherwise returns false.
 o dump(PrintStream)
Dumps current headers to specified PrintStream for debugging.
 o find(String)
Finds and returns the request header matching name.
 o getDateHeader(String)
Returns the date value of the specified header field.
 o getHeader(int)
Returns the value of the nth header field where n >= 0.
 o getHeader(String)
Returns the string value of the specified header field.
 o getHeaderName(int)
Returns the name of the nth header field where n >= 0.
 o getIntHeader(String)
Returns the integer value of the specified header field.
 o names()
Returns an enumeration of strings representing the header field names.
 o putDateHeader(String)
Sets a header field date value to the current time.
 o putDateHeader(String, long)
Sets a header field date value to the specified time.
 o putHeader()
Creates a new header field.
 o putHeader(String)
Searches for a header field corresponding to the specified name and creates a new one if not found.
 o putHeader(String, String)
Sets a header field value to the specified string.
 o putIntHeader(String, int)
Sets a header field value to the specified integer.
 o read(ServletInputStream)
Reads header fields from the specified servlet input stream until a blank line is encountered.
 o removeHeader(String)
Removes the specified header field.
 o size()
Returns the current number of header fields.
 o toString()
Returns a lengthly string representation of the current header fields.
 o write(ServletOutputStream)
Writes out header fields to the specified servlet output stream.

Variables

 o headers
  protected MimeHeaderField headers[]
The header fields.

 o count
  protected int count
The current number of headers.

 o buf
  protected byte buf[]
The byte buffer to use when parsing headers.

Constructors

 o MimeHeaders
  public MimeHeaders(int len)
Creates a new MimeHeaders object using the specified buffer size.

Parameters:
len - the buffer size for parsing headers
 o MimeHeaders
  public MimeHeaders()
Creates a new MimeHeaders object using a default buffer size.

Methods

 o clear
  public void clear()
Clears all header fields.

 o size
  public int size()
Returns the current number of header fields.

 o names
  public Enumeration names()
Returns an enumeration of strings representing the header field names.

 o 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
 o 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
 o 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
 o putDateHeader
  public void putDateHeader(String name)
Sets a header field date value to the current time.

Parameters:
name - the header name
 o 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
 o 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
 o 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
 o 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.

 o 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.

 o find
  protected MimeHeaderField find(String name)
Finds and returns the request header matching name.

 o 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
 o 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
 o 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
 o 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
 o 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
 o putHeader
  protected MimeHeaderField putHeader()
Creates a new header field.

 o toString
  public String toString()
Returns a lengthly string representation of the current header fields.

Overrides:
toString in class Object
 o dump
  public void dump(PrintStream out)
Dumps current headers to specified PrintStream for debugging.


All Packages  Class Hierarchy  This Package  Previous  Next  Index