title: Using HttpResponseInterceptor to manipulate responses
body: <p>With Apache HttpClient, it's possible to manipulate the retrieved content by adding a <code>HttpResponseIntercepter</code>. With this it is quite easy to add header attributes. But how to manipulate the content of the retrieved <code>HttpEntity</code>s?</p>
  
  <p>As example I like to convert all Text to Uppercase.</p>
  
  <pre><code>@Test
  public void shoudConvertEverythingToUpperCase() throws ClientProtocolException, IOException
  {
      final DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
  
      defaultHttpClient.addResponseInterceptor(new HttpResponseInterceptor() {
  
          @Override
          public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException
          {
              final HttpEntity entity = response.getEntity();
  
              final HttpEntity upperCaseEntity = makeAllUppercase(entity);
  
              response.setEntity(upperCaseEntity);
          }
  
          private HttpEntity makeAllUppercase(final HttpEntity entity)
          {
              // how to uppercase everything and return the cloned HttpEntity
              return null;
          }
      });
  
      final HttpResponse httpResponse = defaultHttpClient.execute(new HttpGet("http://stackoverflow.com"));
  
      assertTrue(StringUtils.isAllUpperCase(EntityUtils.toString(httpResponse.getEntity())));
  }
  </code></pre>