Package net.i2p.i2ptunnel
Class HTTPResponseOutputStream
- java.lang.Object
- 
- java.io.OutputStream
- 
- java.io.FilterOutputStream
- 
- net.i2p.i2ptunnel.HTTPResponseOutputStream
 
 
 
- 
- All Implemented Interfaces:
- Closeable,- Flushable,- AutoCloseable
 
 class HTTPResponseOutputStream extends FilterOutputStream This does the transparent gzip decompression on the client side. Extended in I2PTunnelHTTPServer to do the compression on the server side. 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 SummaryFields Modifier and Type Field Description protected String_contentEncodinglower-case, trimmedprotected String_contentTypelower-case, trimmedprotected long_dataExpectedprotected boolean_gzipprotected ByteArray_headerBuffer- 
Fields inherited from class java.io.FilterOutputStreamout
 
- 
 - 
Constructor SummaryConstructors Constructor Description HTTPResponseOutputStream(OutputStream raw)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbeginProcessing()voidclose()protected StringfilterResponseLine(String line)Possibly tweak that first HTTP response line (HTTP/1.0 200 OK, etc).protected voidfinishHeaders()protected booleanshouldCompress()voidwrite(byte[] buf)voidwrite(byte[] buf, int off, int len)voidwrite(int c)- 
Methods inherited from class java.io.FilterOutputStreamflush
 - 
Methods inherited from class java.io.OutputStreamnullOutputStream
 
- 
 
- 
- 
- 
Constructor Detail- 
HTTPResponseOutputStreampublic HTTPResponseOutputStream(OutputStream raw) 
 
- 
 - 
Method Detail- 
writepublic void write(int c) throws IOException- Overrides:
- writein class- FilterOutputStream
- Throws:
- IOException
 
 - 
writepublic void write(byte[] buf) throws IOException- Overrides:
- writein class- FilterOutputStream
- Throws:
- IOException
 
 - 
writepublic void write(byte[] buf, int off, int len) throws IOException- Overrides:
- writein class- FilterOutputStream
- Throws:
- IOException
 
 - 
filterResponseLineprotected String filterResponseLine(String line) Possibly tweak that first HTTP response line (HTTP/1.0 200 OK, etc). Overridden on server side.
 - 
shouldCompressprotected boolean shouldCompress() 
 - 
finishHeadersprotected void finishHeaders() throws IOException- Throws:
- IOException
 
 - 
closepublic void close() throws IOException- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- FilterOutputStream
- Throws:
- IOException
 
 - 
beginProcessingprotected void beginProcessing() throws IOException- Throws:
- IOException
 
 
- 
 
-