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
_contentEncoding
lower-case, trimmedprotected String
_contentType
lower-case, trimmedprotected long
_dataExpected
protected boolean
_gzip
protected ByteArray
_headerBuffer
-
Constructor Summary
Constructors Constructor Description HTTPResponseOutputStream(OutputStream raw)
-
Method Summary
Modifier and Type Method Description protected void
beginProcessing()
void
close()
protected String
filterResponseLine(String line)
Possibly tweak that first HTTP response line (HTTP/1.0 200 OK, etc).protected void
finishHeaders()
protected boolean
shouldCompress()
void
write(byte[] buf)
void
write(byte[] buf, int off, int len)
void
write(int c)
-
Field Details
-
_headerBuffer
-
_gzip
protected boolean _gzip -
_dataExpected
protected long _dataExpected -
_contentType
lower-case, trimmed -
_contentEncoding
lower-case, trimmed
-
-
Constructor Details
-
Method Details
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
filterResponseLine
Possibly tweak that first HTTP response line (HTTP/1.0 200 OK, etc). Overridden on server side. -
shouldCompress
protected boolean shouldCompress() -
finishHeaders
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
-
beginProcessing
- Throws:
IOException
-