// Path: wayback-core/src/main/java/org/archive/wayback/replay/DecodingResource.java
// public class DecodingResource extends Resource {
//     protected Resource source;
// 
//     private DecodingResource(Resource source, InputStream stream) {
//         this.source = source;
//         setInputStream(stream);
//     }
// 
//     @Override
//     public long getRecordLength() {
//         return source.getRecordLength();
//     }
// 
//     @Override
//     public Map<String, String> getHttpHeaders() {
//         return source.getHttpHeaders();
//     }
// 
//     @Override
//     public void close() throws IOException {
//         source.close();
//     }
// 
//     @Override
//     public int getStatusCode() {
//         return source.getStatusCode();
//     }
// 
//     @Override
//     public String getRefersToTargetURI() {
//         return source.getRefersToTargetURI();
//     }
// 
//     @Override
//     public String getRefersToDate() {
//         return source.getRefersToDate();
//     }
// 
//     /**
//      * Returns a DecodingResource that wraps an existing resource with a decompressor for the given
//      * Content-Encoding.
//      *
//      * @param contentEncoding the value of the Content-Encoding header
//      * @param source the resource to wrap
//      * @return the new resource or null if the contentEncoding is not supported
//      */
//     public static DecodingResource forEncoding(String contentEncoding, Resource source) throws IOException {
//         InputStream stream = decodingStream(contentEncoding, source);
//         if (stream == null) {
//             return null;
//         }
//         return new DecodingResource(source, stream);
//     }
// 
//     private static InputStream decodingStream(String contentEncoding, InputStream source) throws IOException {
//         switch (contentEncoding.toLowerCase()) {
//             case "br":
//                 return new BrotliInputStream(source);
//             case "gzip":
//             case "x-gzip":
//                 return new GZIPInputStream(source);
//             default:
//                 return null;
//         }
//     }
// }


import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.archive.wayback.core.Resource;
import org.archive.wayback.replay.DecodingResource;
import org.archive.wayback.replay.charset.CharsetDetector;
import org.archive.wayback.replay.charset.StandardCharsetDetector;
			}
			break;
		}

		if (bytes[2] == '-' && bytes[3] == 'l' && bytes[4] == 'h' && bytes[5] == '5' && bytes[6] == '-') {
			// LZH archive
			return BINARY_FILE;
		}
		// Other formats we may want to add
		// "RIFF" <?><?><?><?> "WAVEfmt " - "audio/wav"
		// <DB><A5><2D><00> - commonly with suffix .doc. files command doesn't know this format.
		// <C5><D0><D3><C6><1E><00><00><00> - some EPS has a binary header starting with this, before "%!PS-"
		return null;
	}

	/**
	 * Read first {@code sniffLength} bytes of {@code resource}'s payload,
	 * decoding {@code Content-Encoding} if any. Reset {@code resource}'s
	 * read position back to zero.
	 * @param resource Resource to load bytes from
	 * @return bytes, zero-padded if payload is shorter.
	 * @throws IOException
	 */
	protected byte[] peekContent(Resource resource) throws IOException {
		byte[] bbuffer = new byte[Math.max(sniffLength, MINIMUM_SNIFF_BUFFER_SIZE)];
		String encoding = resource.getHeader("content-encoding");
		// use larger readlimit, because gzip-ed data can be larger than the original
		// at low compression level.
		resource.mark(sniffLength + 100);
		if (encoding != null) {
// Path: wayback-core/src/main/java/org/archive/wayback/replay/DecodingResource.java
// public class DecodingResource extends Resource {
//     protected Resource source;
// 
//     private DecodingResource(Resource source, InputStream stream) {
//         this.source = source;
//         setInputStream(stream);
//     }
// 
//     @Override
//     public long getRecordLength() {
//         return source.getRecordLength();
//     }
// 
//     @Override
//     public Map<String, String> getHttpHeaders() {
//         return source.getHttpHeaders();
//     }
// 
//     @Override
//     public void close() throws IOException {
//         source.close();
//     }
// 
//     @Override
//     public int getStatusCode() {
//         return source.getStatusCode();
//     }
// 
//     @Override
//     public String getRefersToTargetURI() {
//         return source.getRefersToTargetURI();
//     }
// 
//     @Override
//     public String getRefersToDate() {
//         return source.getRefersToDate();
//     }
// 
//     /**
//      * Returns a DecodingResource that wraps an existing resource with a decompressor for the given
//      * Content-Encoding.
//      *
//      * @param contentEncoding the value of the Content-Encoding header
//      * @param source the resource to wrap
//      * @return the new resource or null if the contentEncoding is not supported
//      */
//     public static DecodingResource forEncoding(String contentEncoding, Resource source) throws IOException {
//         InputStream stream = decodingStream(contentEncoding, source);
//         if (stream == null) {
//             return null;
//         }
//         return new DecodingResource(source, stream);
//     }
// 
//     private static InputStream decodingStream(String contentEncoding, InputStream source) throws IOException {
//         switch (contentEncoding.toLowerCase()) {
//             case "br":
//                 return new BrotliInputStream(source);
//             case "gzip":
//             case "x-gzip":
//                 return new GZIPInputStream(source);
//             default:
//                 return null;
//         }
//     }
// }


// Path: wayback-core/src/main/java/org/archive/wayback/replay/mimetype/SimpleMimeTypeDetector.java
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.archive.wayback.core.Resource;
import org.archive.wayback.replay.DecodingResource;
import org.archive.wayback.replay.charset.CharsetDetector;
import org.archive.wayback.replay.charset.StandardCharsetDetector;

			}
			break;
		}

		if (bytes[2] == '-' && bytes[3] == 'l' && bytes[4] == 'h' && bytes[5] == '5' && bytes[6] == '-') {
			// LZH archive
			return BINARY_FILE;
		}
		// Other formats we may want to add
		// "RIFF" <?><?><?><?> "WAVEfmt " - "audio/wav"
		// <DB><A5><2D><00> - commonly with suffix .doc. files command doesn't know this format.
		// <C5><D0><D3><C6><1E><00><00><00> - some EPS has a binary header starting with this, before "%!PS-"
		return null;
	}

	/**
	 * Read first {@code sniffLength} bytes of {@code resource}'s payload,
	 * decoding {@code Content-Encoding} if any. Reset {@code resource}'s
	 * read position back to zero.
	 * @param resource Resource to load bytes from
	 * @return bytes, zero-padded if payload is shorter.
	 * @throws IOException
	 */
	protected byte[] peekContent(Resource resource) throws IOException {
		byte[] bbuffer = new byte[Math.max(sniffLength, MINIMUM_SNIFF_BUFFER_SIZE)];
		String encoding = resource.getHeader("content-encoding");
		// use larger readlimit, because gzip-ed data can be larger than the original
		// at low compression level.
		resource.mark(sniffLength + 100);
		if (encoding != null) {
			Resource decoded = DecodingResource.forEncoding(encoding, resource);