title: How to compress a Http Post Body using GZIP
body: <p>My team and I have a Tomcat server running a Restfull webservice, implemented using RestEasy:</p>
  
  <pre><code>@POST
  @GZIP
  @Path("/capture")   
  @Consumes(MediaType.APPLICATION_JSON)
  Response RecieveData(@GZIP RecievingData recievingData);
  </code></pre>
  
  <p>We need to make compressed post to this service. The problem is we are not finding an implementation that works.</p>
  
  <ul>
  <li>We tried using interceptors:
  <a href="https://hc.apache.org/httpcomponents-client-4.2.x/httpclient/examples/org/apache/http/examples/client/ClientGZipContentCompression.java" rel="nofollow">https://hc.apache.org/httpcomponents-client-4.2.x/httpclient/examples/org/apache/http/examples/client/ClientGZipContentCompression.java</a>. But we were unable to capture the POST request Body and compress it.</li>
  <li><p>We tried using the RestEasy client but it doesn´t seems to be compreesing the body of the Post Request: www.posttestserver.com/data/2016/01/06/15.33.391016591335</p></li>
  <li><p>Finally we tried a customized class: <a href="https://gist.github.com/takumakei/913067" rel="nofollow">https://gist.github.com/takumakei/913067</a>. But we got a 400 error on the request:</p></li>
  </ul>
  
  <blockquote>
    <p>HTTP/1.1 400 Bad Request [Content-Encoding: gzip, Content-Type:
    text/html; charset=UTF-8, Date: Thu, 07 Jan 2016 10:07:05 GMT, Server:
    Apache-Coyote/1.1, Content-Length: 66, Connection: keep-alive]</p>
  </blockquote>
  
  <p>We are out of ideas and this supose to be a simple function for an HTTP Client. Any ideas?</p>
  
  <p>OBS: Here is the RestEasy Proxy:</p>
  
  <pre><code>@POST   
  @GZIP
  @Consumes(MediaType.APPLICATION_JSON)
  public Response saveData(@GZIP RecievingData customer);
  </code></pre>
  
  <p>EDIT: Got some changes in the Firewall and the 3rd method changed to an error 400.</p>