private static feign.Response.Body toBody(final ResponseBody input) throws IOException {
    if (input == null || input.contentLength() == 0) {
      if (input != null) {
        input.close();
      }
      return null;
    }
    final Integer length =
        input.contentLength() >= 0 && input.contentLength() <= Integer.MAX_VALUE
            ? (int) input.contentLength()
            : null;

    return new feign.Response.Body() {

      @Override
      public void close() throws IOException {
        input.close();
      }

      @Override
      public Integer length() {
        return length;
      }

      @Override
      public boolean isRepeatable() {
        return false;
      }

      @Override
      public InputStream asInputStream() throws IOException {
        return input.byteStream();
      }

      @SuppressWarnings("deprecation")
      @Override
      public Reader asReader() throws IOException {
        return input.charStream();
      }

      @Override
      public Reader asReader(Charset charset) throws IOException {
        return asReader();
      }
    };
  }
This module directs Feign's http requests to
<a href="http://square.github.io/okhttp/">OkHttp</a>, which enables SPDY and better network
control. Ex.

<pre>
GitHub github = Feign.builder().client(new OkHttpClient()).target(GitHub.class,
"https://api.github.com");
okhttp/src/main/java/feign/okhttp/OkHttpClient.java