private final CountingOutputStream compressed;
private ReportingOutputStream(HttpURLConnection connection, OutputStream out,
boolean gzipEncode) {
super(new CountingOutputStream(out));
this.gzipEncode = gzipEncode;
this.connection = connection;
compressed = (CountingOutputStream) super.out;
if (gzipEncode) {
GZIPOutputStream gzipOut;
try {
gzipOut = new GZIPOutputStream(compressed);
} catch (IOException e) {
throw Throwables.propagate(e);
}
uncompressed = new CountingOutputStream(gzipOut);
super.out = uncompressed;
} else {
uncompressed = compressed;
}
}