com.caucho.vfs
Class HttpStreamWrapper

java.lang.Object
  extended by com.caucho.vfs.StreamImpl
      extended by com.caucho.vfs.HttpStreamWrapper

public class HttpStreamWrapper
extends StreamImpl

Facade to HttpStream to properly handle the close.


Field Summary
 
Fields inherited from class com.caucho.vfs.StreamImpl
_nullPath, _path
 
Method Summary
 boolean canRead()
          The stream is readable.
 boolean canWrite()
          The stream is always writable (?)
 void close()
          Close the connection.
 java.lang.Object getAttribute(java.lang.String name)
          Returns a header from the response returned from the HTTP server.
 java.util.Iterator getAttributeNames()
          Returns an iterator of the returned header names.
 int getAvailable()
          Returns the bytes still available.
 java.lang.String getHost()
          Returns the stream's host.
 int getPort()
          Returns the stream's port.
 boolean isSSL()
          Set if this should be an SSL connection.
 int read(byte[] buf, int offset, int length)
          Read data from the connection.
 void removeAttribute(java.lang.String name)
          Remove a header for the request.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Sets a header for the request.
 void setHead(boolean isHead)
          Sets true if we're only interested in the head.
 void setHttp10()
          Sets the http version.
 void setHttp11()
          Sets the http version.
 void setMethod(java.lang.String method)
          Sets the method
 void setSocketTimeout(long timeout)
          Sets the timeout.
 void setSSL(boolean isSSL)
          Set if this should be an SSL connection.
 void write(byte[] buf, int offset, int length, boolean isEnd)
          Writes a buffer to the underlying stream.
 
Methods inherited from class com.caucho.vfs.StreamImpl
clearWrite, closeWrite, flush, flushBuffer, flushToDisk, getFlushOnNewline, getNewline, getPath, getReadBuffer, getReadPosition, hasSkip, isClosed, isEof, readNonBlock, readTimeout, seekEnd, seekStart, setPath, setWriteEncoding, skip, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setSSL

public void setSSL(boolean isSSL)
Set if this should be an SSL connection.


isSSL

public boolean isSSL()
Set if this should be an SSL connection.


setMethod

public void setMethod(java.lang.String method)
Sets the method


setHead

public void setHead(boolean isHead)
Sets true if we're only interested in the head.


getHost

public java.lang.String getHost()
Returns the stream's host.


getPort

public int getPort()
Returns the stream's port.


setHttp10

public void setHttp10()
Sets the http version.


setHttp11

public void setHttp11()
Sets the http version.


getAttribute

public java.lang.Object getAttribute(java.lang.String name)
                              throws java.io.IOException
Returns a header from the response returned from the HTTP server.

Overrides:
getAttribute in class StreamImpl
Parameters:
name - name of the header
Returns:
the header value.
Throws:
java.io.IOException

getAttributeNames

public java.util.Iterator getAttributeNames()
                                     throws java.io.IOException
Returns an iterator of the returned header names.

Overrides:
getAttributeNames in class StreamImpl
Throws:
java.io.IOException

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Sets a header for the request.

Overrides:
setAttribute in class StreamImpl
Parameters:
name - the attribute name.
value - the attribute value.

removeAttribute

public void removeAttribute(java.lang.String name)
Remove a header for the request.

Overrides:
removeAttribute in class StreamImpl
Parameters:
name - the attribute name.

setSocketTimeout

public void setSocketTimeout(long timeout)
                      throws java.net.SocketException
Sets the timeout.

Throws:
java.net.SocketException

canWrite

public boolean canWrite()
The stream is always writable (?)

Overrides:
canWrite in class StreamImpl

write

public void write(byte[] buf,
                  int offset,
                  int length,
                  boolean isEnd)
           throws java.io.IOException
Writes a buffer to the underlying stream.

Overrides:
write in class StreamImpl
Parameters:
buffer - the byte array to write.
offset - the offset into the byte array.
length - the number of bytes to write.
isEnd - true when the write is flushing a close.
Throws:
java.io.IOException

canRead

public boolean canRead()
The stream is readable.

Overrides:
canRead in class StreamImpl

read

public int read(byte[] buf,
                int offset,
                int length)
         throws java.io.IOException
Read data from the connection. If the request hasn't yet been sent to the server, send it.

Overrides:
read in class StreamImpl
Parameters:
buf - byte array receiving the data.
offset - starting offset into the array.
length - number of bytes to read.
Returns:
the number of bytes read or -1 on end of file.
Throws:
java.io.IOException

getAvailable

public int getAvailable()
                 throws java.io.IOException
Returns the bytes still available.

Overrides:
getAvailable in class StreamImpl
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Close the connection.

Overrides:
close in class StreamImpl
Throws:
java.io.IOException