|
|
@ -70,22 +70,29 @@ class SmartOutputStream extends TemporaryBuffer { |
|
|
|
private static final int LIMIT = 32 * 1024; |
|
|
|
private static final int LIMIT = 32 * 1024; |
|
|
|
|
|
|
|
|
|
|
|
private final HttpServletRequest req; |
|
|
|
private final HttpServletRequest req; |
|
|
|
|
|
|
|
|
|
|
|
private final HttpServletResponse rsp; |
|
|
|
private final HttpServletResponse rsp; |
|
|
|
|
|
|
|
private boolean compressStream; |
|
|
|
private boolean startedOutput; |
|
|
|
private boolean startedOutput; |
|
|
|
|
|
|
|
|
|
|
|
SmartOutputStream(final HttpServletRequest req, |
|
|
|
SmartOutputStream(final HttpServletRequest req, |
|
|
|
final HttpServletResponse rsp) { |
|
|
|
final HttpServletResponse rsp, |
|
|
|
|
|
|
|
boolean compressStream) { |
|
|
|
super(LIMIT); |
|
|
|
super(LIMIT); |
|
|
|
this.req = req; |
|
|
|
this.req = req; |
|
|
|
this.rsp = rsp; |
|
|
|
this.rsp = rsp; |
|
|
|
|
|
|
|
this.compressStream = compressStream; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected OutputStream overflow() throws IOException { |
|
|
|
protected OutputStream overflow() throws IOException { |
|
|
|
startedOutput = true; |
|
|
|
startedOutput = true; |
|
|
|
return rsp.getOutputStream(); |
|
|
|
|
|
|
|
|
|
|
|
OutputStream out = rsp.getOutputStream(); |
|
|
|
|
|
|
|
if (compressStream && acceptsGzipEncoding(req)) { |
|
|
|
|
|
|
|
rsp.setHeader(HDR_CONTENT_ENCODING, ENCODING_GZIP); |
|
|
|
|
|
|
|
out = new GZIPOutputStream(out); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return out; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void close() throws IOException { |
|
|
|
public void close() throws IOException { |
|
|
|