/*
* What we will send is an image or some other sort of
* binary
*/
if (content instanceof HTMLImage) {
final HTMLImage img = (HTMLImage) content;
/*
* the HTMLImage class provides us with most of the
* necessary information that we want to send
*/
res.setHeader("Content-Type", img.getContentType());
res.setHeader("Content-Transfer-Encoding",
img.getContentEncoding());
res.setHeader("Content-Length", "" + img.size());
res.setHeader("Connection", "Keep-Alive");
/* Send 8k junks */
int offset = 0;
while (offset + chunk_size < img.size()) {
out.write(img.toBinary(), offset, chunk_size);
offset += chunk_size;
}
out.write(img.toBinary(), offset, img.size() - offset);
out.flush();
out.close();
} else {
final byte[] encoded_content =