stream.reset();
// Select decompression or unpacking mechanism based on the two bytes
if (a == 'B' && b == 'Z') {
metadata.set(Metadata.CONTENT_TYPE, "application/x-bzip");
decompress(new BZip2CompressorInputStream(stream), xhtml);
} else if (a == 0x1f && b == 0x8b) {
metadata.set(Metadata.CONTENT_TYPE, "application/x-gzip");
decompress(new GZIPInputStream(stream), xhtml);
} else if (a == 'P' && b == 'K') {
metadata.set(Metadata.CONTENT_TYPE, "application/zip");