if (!startedOutput) {
// If output hasn't started yet, the entire thing fit into our
// buffer. Try to use a proper Content-Length header, and also
// deflate the response with gzip if it will be smaller.
TemporaryBuffer out = this;
if (256 < out.length() && acceptsGzipEncoding(req)) {
TemporaryBuffer gzbuf = new TemporaryBuffer.Heap(LIMIT);
try {
GZIPOutputStream gzip = new GZIPOutputStream(gzbuf);
try {
out.writeTo(gzip, null);
} finally {
gzip.close();
}
if (gzbuf.length() < out.length()) {
out = gzbuf;
rsp.setHeader(HDR_CONTENT_ENCODING, ENCODING_GZIP);
}
} catch (IOException err) {
// Most likely caused by overflowing the buffer, meaning