net.i2p.i2ptunnel
Class HTTPResponseOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by net.i2p.i2ptunnel.HTTPResponseOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

 class HTTPResponseOutputStream
extends java.io.FilterOutputStream

Simple stream for delivering an HTTP response to the client, trivially filtered to make sure "Connection: close" is always in the response. Perhaps add transparent handling of the Content-encoding: x-i2p-gzip, adjusting the headers to say Content-encoding: identity? Content-encoding: gzip is trivial as well, but Transfer-encoding: chunked makes it more work than is worthwhile at the moment.


Field Summary
protected  boolean _gzip
           
protected  ByteArray _headerBuffer
           
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
HTTPResponseOutputStream(java.io.OutputStream raw)
           
 
Method Summary
protected  void beginProcessing()
           
 void close()
           
protected static java.lang.String filterResponseLine(java.lang.String line)
          Tweak that first HTTP response line (HTTP 200 OK, etc)
protected  void finishHeaders()
           
protected  boolean shouldCompress()
           
 java.lang.String toString()
           
 void write(byte[] buf)
           
 void write(byte[] buf, int off, int len)
           
 void write(int c)
           
 
Methods inherited from class java.io.FilterOutputStream
flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_headerBuffer

protected ByteArray _headerBuffer

_gzip

protected boolean _gzip
Constructor Detail

HTTPResponseOutputStream

public HTTPResponseOutputStream(java.io.OutputStream raw)
Method Detail

write

public void write(int c)
           throws java.io.IOException
Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

write

public void write(byte[] buf)
           throws java.io.IOException
Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

write

public void write(byte[] buf,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

filterResponseLine

protected static java.lang.String filterResponseLine(java.lang.String line)
Tweak that first HTTP response line (HTTP 200 OK, etc)


shouldCompress

protected boolean shouldCompress()

finishHeaders

protected void finishHeaders()
                      throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterOutputStream
Throws:
java.io.IOException

beginProcessing

protected void beginProcessing()
                        throws java.io.IOException
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object