final Repository db = getRepository(req);
final OutputStreamWriter out = new OutputStreamWriter(
- new SmartOutputStream(req, rsp), Constants.CHARSET);
+ new SmartOutputStream(req, rsp, true),
+ Constants.CHARSET);
final RefAdvertiser adv = new RefAdvertiser() {
@Override
protected void writeOne(final CharSequence line) throws IOException {
private static final int LIMIT = 32 * 1024;
private final HttpServletRequest req;
-
private final HttpServletResponse rsp;
-
+ private boolean compressStream;
private boolean startedOutput;
SmartOutputStream(final HttpServletRequest req,
- final HttpServletResponse rsp) {
+ final HttpServletResponse rsp,
+ boolean compressStream) {
super(LIMIT);
this.req = req;
this.rsp = rsp;
+ this.compressStream = compressStream;
}
@Override
protected OutputStream overflow() throws IOException {
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 {
throws IOException {
final HttpServletRequest req = (HttpServletRequest) request;
final HttpServletResponse res = (HttpServletResponse) response;
- final SmartOutputStream buf = new SmartOutputStream(req, res);
+ final SmartOutputStream buf = new SmartOutputStream(req, res, true);
try {
res.setContentType(infoRefsResultType(svc));