public static InputStream unzipStreamIfNeeded(final HttpRequest httpRequest) throws IOException {
        String contentEncodingHeader = httpRequest.getHeader("content-encoding");
        if ("gzip".equals(contentEncodingHeader)) {
            return new GZIPInputStream(httpRequest.getData());
        } else {
            return httpRequest.getData();
        }
    }
This code is based on v2 code, but restructured so stream reading code is in one dedicated class.

@author Haakon Dybdahl
vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/StreamReaderV3.java