if ( reply_bytes.length < 512*1024 ){
ByteArrayOutputStream temp = new ByteArrayOutputStream( reply_bytes.length );
GZIPOutputStream gzos = new GZIPOutputStream(temp);
gzos.write( reply_bytes );
gzos.finish();
reply_bytes = temp.toByteArray();
do_gzip = false;
}
}
reply_header +=
"Content-Length: " + reply_bytes.length + NL +
NL;
// System.out.println( "writing reply:" + reply_header );
OutputStream os = request.getOutputStream();
os.write( reply_header.getBytes());
if ( do_gzip ){
GZIPOutputStream gzos = new GZIPOutputStream(os);
gzos.write( reply_bytes );
gzos.finish();
}else{
os.write( reply_bytes );
}