private MediaType detectSpecialization(InputStream input, Metadata metadata) throws IOException {

        int buffSize = 1024;
        UnsynchronizedByteArrayOutputStream gzippedBytes = UnsynchronizedByteArrayOutputStream.builder().get();
        try {
            IOUtils.copyLarge(input, gzippedBytes, 0, buffSize);
        } catch (IOException e) {
            //swallow
        } finally {
            input.reset();
        }
        UnsynchronizedByteArrayOutputStream bytes = UnsynchronizedByteArrayOutputStream.builder().get();
        try (InputStream is = new
                     GzipCompressorInputStream(UnsynchronizedByteArrayInputStream.builder().setByteArray(gzippedBytes.toByteArray()).get())) {
            int c = is.read();
            //read bytes one at a time to avoid premature EOF from buffering
            while (c > -1) {
                bytes.write(c);
                c = is.read();
            }
        } catch (IOException e) {
            //swallow
        }
        //TODO: something better than this
        String s = new String(bytes.toByteArray(), StandardCharsets.UTF_8);
        if (s.startsWith("WARC/")) {
            return WARC_GZ;
        } else if (s.startsWith("filedesc://")) {
            return ARC_GZ;
        }
        return GZ;
    }
This is designed to detect commonly gzipped file types such as warc.gz.
This is a first step.  We still need to implement tar.gz and svg.gz and ???
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-pkg-module/src/main/java/org/apache/tika/detect/gzip/GZipSpecializationDetector.java