title: content Length of OutputStream
body: <p>I want to to gzip when size of output stream is greater than 100 bytes . 
  I am trying various approaches but couldn’t get how can I get content-length from output stream .Value from
  Content-length in httpheader is incorrect </p>
  
  <p>Could you please help me how can I find length of output stream </p>
  
  <pre><code>@Provider
  @Compress
  public class GzipInterceptor implements WriterInterceptor {
  
    @Context
    private HttpHeaders httpHeaders;
  
    @Override
    public void aroundWriteTo(WriterInterceptorContext context)
        throws IOException, WebApplicationException {
  
      List&lt;String&gt; acceptEncoding = null;
      if (httpHeaders != null) {
        MultivaluedMap&lt;String, String&gt; requestHeaders = httpHeaders.getRequestHeaders();
        acceptEncoding = requestHeaders.get(HttpHeaders.ACCEPT_ENCODING);
      }
  
      if (acceptEncoding != null) {
        for (String s : acceptEncoding) {
  
          if (s.contains(“gzip”)) {
              MultivaluedMap&lt;String, Object&gt; headers = context.getHeaders();
              OutputStream os = context.getOutputStream();
              if(//content-legth greater than 100 bytes)//I need some help here {
              headers.add(HttpHeaders.CONTENT_ENCODING, “”gzip”);
              context.setOutputStream(new GZIPOutputStream(os));
             }
            break;
          }
        }
      }
  
      context.proceed();
    }
  
  }
  </code></pre>
  
  <p>Thanks for your help </p>