title: Android Annotations Logging Interceptor end-of-input error
body: <p>I am using Android Annotations to make requests to a server. I created the following interceptor based on the answer to this <a href="https://stackoverflow.com/questions/30912343/androidannotations-rest-view-response-data">question</a> </p>
  
  <pre><code>public class LoggingInterceptor implements ClientHttpRequestInterceptor {
  
  @Override
  public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
      ClientHttpResponse response = execution.execute(request, body);
  
      //It works after removing these two lines
      String responseString = stringOf(response.getBody());
      Log.d("RESPONSE", responseString);
  
      return response;
  }
  
  public static String stringOf(InputStream inputStream) {
      inputStream.mark(Integer.MAX_VALUE);
      BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
      StringBuilder strBuilder = new StringBuilder();
      String line;
      try {
          while ((line = r.readLine()) != null)
              strBuilder.append(line);
      } catch (IOException ignored) {}
      try {
          inputStream.reset();
      } catch (IOException ignored) {}
      return strBuilder.toString();
   }
  }
  </code></pre>
  
  <p>However, this is producing the following exception: <strong>org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: No content to map due to end-of-input</strong></p>
  
  <p>When I remove the following lines from the interceptor:</p>
  
  <pre><code> String responseString = stringOf(response.getBody());
   Log.d("RESPONSE", responseString);
  </code></pre>
  
  <p>Everything works fine.</p>
  
  <p><strong>Here is my RestClient interface:</strong></p>
  
  <pre><code> @Rest(rootUrl= "http://107.206.158.62:1337/api/", converters={MappingJackson2HttpMessageConverter.class}, interceptors = { LoggingInterceptor.class })
   public interface IRestClient {
  
       @Post("users/register/")
       @Accept(MediaType.APPLICATION_JSON)
       User register(@Body User user);
  
  }
  </code></pre>
  
  <p><strong>User Model:</strong></p>
  
  <pre><code>public class User implements Serializable {
  
      String first_name;
  
      String last_name;
  
      String email;
  
      String password;
  
      public User(){}
  
      public User(String first_name, String last_name, String email, String password) {
         this.first_name = first_name;
         this.last_name = last_name;
         this.email = email;
         this.password = password;
      }
  
      //Getters and Setters
  }
  </code></pre>
  
  <p><strong>RestClient call in my Activity</strong></p>
  
  <pre><code>@Click(R.id.bRegister)
  @Background
  void createAccount() {
      User u = restClient.register(new User("Test Fname", "Test Lname", "test@test.com", "testpass"));
      Log.d("User last name", u.getLast_name());
   }
  </code></pre>
  
  <p>The server produces the following json:</p>
  
  <pre><code>{"first_name":"Test Fname","last_name":"Test Lname","email":"test@test.com"}
  </code></pre>
  
  <p>I'd like to be able to log the body of each response, and then return the response object. But it appears that reading the InputStream from the response first is causing some problems.</p>
  
  <pre><code> Log.d("RESPONSE", responseString);
  </code></pre>
  
  <p>Is yielding the correct server response, but then I run into the above exception when the <strong>MappingJackson2HttpMessageConverter</strong> kicks in.</p>
  
  <p>Any help would be greatly appreciated! Happy New Years! :)</p>