Class sun.server.http.HttpInputStream
All Packages Class Hierarchy This Package Previous Next Index
Class sun.server.http.HttpInputStream
java.lang.Object
|
+----java.io.InputStream
|
+----java.servlet.ServletInputStream
|
+----sun.server.http.HttpInputStream
- public class HttpInputStream
- extends ServletInputStream
- implements AlarmHandler
A buffered input stream for reading HTTP server requests. Unlike
java.io.BufferedInputStream, this class is not synchronized in
order to be as efficient as possible. Consequently, it is not MT-safe
so must be used carefully in servlets that create multiple threads.
This class also includes additional support for automatically closing
the connection when input becomes idle, in order to support keep-alive.
-
alarm
- The alarm for supporting timeout on input.
-
am
-
-
buf
- The buffer where input data is stored.
-
chunkIn
- If we are doing chunking, delegate to this stream.
-
chunking
- Whether we are doing HTTP/1.1 chunking or not.
-
closed
- Set to true when the connection is closed.
-
count
- The number of bytes in the buffer.
-
in
- The socket input stream.
-
pos
- The current position in the buffer.
-
timeout
- The maximum time to block while reading before the input stream
is closed.
-
HttpInputStream()
- Creates a new HTTP input stream with a default buffer size.
-
HttpInputStream(int)
- Creates a new HTTP input stream with the specified buffer size.
-
available()
- Returns the number of bytes that can be read without blocking.
-
close()
- Closes the input stream.
-
eof()
- Returns true if at end of stream.
-
fill()
- Fills the input buffer with more data.
-
handleAlarm(Alarm)
- The handler for timeout alarm events.
-
read()
- Reads a byte of data.
-
read(byte[], int, int)
- Reads into an array of bytes.
-
readLine(byte[], int, int)
- Reads bytes into the specified byte array until the array is filled
or a newline character is read.
-
reset(InputStream, long)
- Resets the input stream for a new connection.
-
skip(long)
- Skips n bytes of input.
-
startChunking()
- Use HTTP/1.1 chunking for input.
am
protected static AlarmManager am
in
protected InputStream in
- The socket input stream.
buf
protected byte buf[]
- The buffer where input data is stored.
count
protected int count
- The number of bytes in the buffer.
pos
protected int pos
- The current position in the buffer.
alarm
protected Alarm alarm
- The alarm for supporting timeout on input.
timeout
protected long timeout
- The maximum time to block while reading before the input stream
is closed.
closed
protected boolean closed
- Set to true when the connection is closed.
chunking
protected boolean chunking
- Whether we are doing HTTP/1.1 chunking or not.
chunkIn
protected ChunkedInputStream chunkIn
- If we are doing chunking, delegate to this stream.
HttpInputStream
public HttpInputStream(int size)
- Creates a new HTTP input stream with the specified buffer size.
- Parameters:
- size - the input buffer size
HttpInputStream
public HttpInputStream()
- Creates a new HTTP input stream with a default buffer size.
reset
public void reset(InputStream in,
long timeout)
- Resets the input stream for a new connection.
- Parameters:
- in - the socket input stream
- timeout - input idle timeout
read
public int read() throws IOException
- Reads a byte of data. This method will block if no input is available.
- Returns:
- the byte read, or -1 if the end of the stream is reached.
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- read in class InputStream
read
public int read(byte b[],
int off,
int len) throws IOException
- Reads into an array of bytes. This method will block until some
input is available.
- Parameters:
- b - the buffer into which the data is read
- off - the start offset of the data
- len - the maximum number of bytes to read
- Returns:
- the actual number of bytes read, or -1 if the end of the
stream is reached.
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- read in class InputStream
readLine
public int readLine(byte b[],
int off,
int len) throws IOException
- Reads bytes into the specified byte array until the array is filled
or a newline character is read.
- Parameters:
- b - the buffer where data is stored
- off - the start offset of the data
- len - the length of the data
- Returns:
- the actual number of bytes read, or -1 if the end of the
file has been reached.
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- readLine in class ServletInputStream
skip
public long skip(long n) throws IOException
- Skips n bytes of input.
- Parameters:
- n - the number of bytes to skip
- Returns:
- the actual number of bytes skipped.
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- skip in class InputStream
available
public int available() throws IOException
- Returns the number of bytes that can be read without blocking.
- Returns:
- the number of available bytes.
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- available in class InputStream
eof
public boolean eof() throws IOException
- Returns true if at end of stream.
- Throws: IOException
- If an I/O error has occurred.
fill
protected void fill() throws IOException
- Fills the input buffer with more data.
handleAlarm
public void handleAlarm(Alarm alarm)
- The handler for timeout alarm events.
close
public void close()
- Closes the input stream.
- Overrides:
- close in class InputStream
startChunking
public void startChunking()
- Use HTTP/1.1 chunking for input.
All Packages Class Hierarchy This Package Previous Next Index