@Override
      public void handle(Request request, HttpServletResponse response) {
        response.setStatus(HTTP_OK);
        if (!"gzip".equals(request.getHeader("Accept-Encoding")))
          return;

        response.setHeader("Content-Encoding", "gzip");
        GZIPOutputStream output;
        try {
          output = new GZIPOutputStream(response.getOutputStream());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
        try {
          output.write("hello compressed".getBytes(CHARSET_UTF8));
        } catch (IOException e) {
          throw new RuntimeException(e);
        } finally {
          try {
            output.close();
          } catch (IOException ignored) {
            // Ignored
          }
        }
      }
Make a GET request that should be compressed

@throws Exception
lib/src/test/java/com/github/kevinsawicki/http/HttpRequestTest.java