GzipResource implements Resource { @Override public Collection<String> headers() throws IOException { return ImmutableList.<String>builder() .addAll(this.resource.headers()) .add(String.format("%s: %s", HttpHeaders.CONTENT_ENCODING, "gzip")) .build(); } GzipResource(final Resource res); @Override int status(); @Override long writeTo(final OutputStream stream); @Override Collection<String> headers(); @Override String etag(); @Override Date lastModified(); @Override String contentType(); @Override void close();  }
@Test public void containsContentEncodingHeader() throws Exception { MatcherAssert.assertThat( new GzipResource(new Resource.PlainText("foo")).headers(), Matchers.hasItem("Content-Encoding: gzip") ); }