title: How to send zipped http request?
body: <p>I want to send a zipped request body as a POST http request for a web-service based application. Can anybody please help me how can I send a zipped http request or how can i send a zipped request body as part of POST http request?</p>
  
  <p><strong>Edit</strong>: <em>Adding the solution here</em></p>
  
  <pre><code>HttpURLConnection request = null; 
  StringBuilder sb = new StringBuilder(getFileAsString("TestFile.txt")); 
  String fileStr = getFileAsString("TestFile.txt"); 
  HttpClient client = new HttpClient(); 
  client.getState().setCredentials(
      new AuthScope(hostip, port), 
      new UsernamePasswordCredentials("username", "password")); 
  PutMethod post = new PutMethod(url); 
  post.setRequestHeader("Content-Encoding", "gzip")
  </code></pre>