class HTTPResponseOutputStream extends FilterOutputStream
Extended in I2PTunnelHTTPServer for server-side compression. Simple filtered response stream ensuring "Connection: close" header. Could handle Content-Encoding: x-i2p-gzip transparently, adjusting to Content-Encoding: identity. gzip encoding trivial, but chunked transfer encoding adds complexity.
| Modifier and Type | Field and Description |
|---|---|
protected String |
_contentEncoding
lower-case, trimmed
|
protected String |
_contentType
lower-case, trimmed
|
protected long |
_dataExpected |
protected boolean |
_gzip |
protected ByteArray |
_headerBuffer |
protected boolean |
_keepAliveIn |
protected boolean |
_keepAliveOut |
out| Constructor and Description |
|---|
HTTPResponseOutputStream(OutputStream raw) |
HTTPResponseOutputStream(OutputStream raw,
boolean allowKeepAliveIn,
boolean allowKeepAliveOut,
boolean isHead,
LimitOutputStream.DoneCallback cb)
Optionally keep sockets alive and call callback when we're done.
|
| Modifier and Type | Method and 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() |
boolean |
getKeepAliveIn()
Should we keep the input stream alive when done?
|
boolean |
getKeepAliveOut()
Should we keep the output stream alive when done?
Only supported for the browser socket side.
|
protected boolean |
shouldCompress() |
void |
write(byte[] buf,
int off,
int len) |
void |
write(int c) |
flush, writeprotected String _contentEncoding
protected String _contentType
protected volatile long _dataExpected
protected volatile boolean _gzip
protected ByteArray _headerBuffer
protected volatile boolean _keepAliveIn
protected volatile boolean _keepAliveOut
public HTTPResponseOutputStream(OutputStream raw)
public HTTPResponseOutputStream(OutputStream raw, boolean allowKeepAliveIn, boolean allowKeepAliveOut, boolean isHead, LimitOutputStream.DoneCallback cb)
allowKeepAliveIn - We may, but are not required to, keep the input socket alive.
This is the server on the server side and I2P on the client side.allowKeepAliveOut - We may, but are not required to, keep the output socket alive.
This is I2P on the server side and the browser on the client side.isHead - is this a response to a HEAD, and thus no data is expected (RFC 2616 sec. 4.4)cb - non-null if allowKeepAlive is trueprotected void beginProcessing()
throws IOException
IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class FilterOutputStreamIOExceptionprotected String filterResponseLine(String line)
protected void finishHeaders()
throws IOException
IOExceptionpublic boolean getKeepAliveIn()
public boolean getKeepAliveOut()
protected boolean shouldCompress()
public void write(byte[] buf,
int off,
int len)
throws IOException
write in class FilterOutputStreamIOExceptionpublic void write(int c)
throws IOException
write in class FilterOutputStreamIOException