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 Summary
Fields 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.FilterOutputStream
out
-
-
Constructor Summary
Constructors Constructor Description HTTPResponseOutputStream(OutputStream raw)
-
Method Summary
All 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.FilterOutputStream
flush
-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Constructor Detail
-
HTTPResponseOutputStream
public HTTPResponseOutputStream(OutputStream raw)
-
-
Method Detail
-
write
public void write(int c) throws IOException- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
write
public void write(byte[] buf) throws IOException- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
write
public void write(byte[] buf, int off, int len) throws IOException- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
filterResponseLine
protected String filterResponseLine(String line)
Possibly tweak that first HTTP response line (HTTP/1.0 200 OK, etc). Overridden on server side.
-
shouldCompress
protected boolean shouldCompress()
-
finishHeaders
protected void finishHeaders() throws IOException- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException
-
beginProcessing
protected void beginProcessing() throws IOException- Throws:
IOException
-
-