title: retrofit & okhttpclient intercept 401 response
body: <p>I'm trying to see whenever I get a response from my API with code 401.
  But when I do, i get an IOException</p>
  
  <pre><code>@Override
  public Response intercept(Chain chain) throws IOException {
      Request request = chain.request();
      Response response = chain.proceed(request);
      if (response.code() == 401) {
          mLoginToken.delete();
          Toast.makeText(mApplication.getApplicationContext(), R.string.session_error, Toast.LENGTH_SHORT).show();
          Intent intent = new Intent(mApplication.getApplicationContext(), LoginActivity.class);
          intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
          mApplication.startActivity(intent);
      }
      return response;
  }
  </code></pre>
  
  <p>I will get the error
  java.io.IOException: unexpected end of stream on Connection{ proxy=DIRECT@ hostAddress= cipherSuite=none protocol=http/1.1} (recycle count=0)</p>
  
  <p>At the line</p>
  
  <pre><code>        Response response = chain.proceed(request);
  </code></pre>
  
  <p>How should I get the responses with 401 (unauthorized code) in order to handle this?</p>