title: How to detect a redirection in Glide v4 / OkHttp3?
body: <p>Using Glide v4 and OkHttp3, how can I detect a redirection and load another url when it happens?</p>
  
  <p>My usecase: I use the Glide v4 library with OkHttp3 to download pictures in my app. Sometimes when a picture is not available, a redirection is performed by the server to provide another picture instead of the one I originaly wanted. I can see it in my browser because when I request url A, I finally land on url B with the second picture. When that happens I want to instead load url C that is derived from url A (so not a static url).</p>
  
  <p>At the moment I can detect the redirection using an OkHttp3 Interceptor:</p>
  
  <pre><code>public Response intercept(@NonNull Chain chain) throws IOException {
      String requestUrl = chain.request().url().toString();
      Response response = chain.proceed(chain.request());
      String responseUrl = response.request().url().toString();
  
      boolean redirect = !requestUrl.equals(responseUrl);
      if (redirect) {
          Timber.d("Detected redirection");
      }
  
      return response;
  }
  </code></pre>
  
  <p>but then I don't know how to cleanly load url C. I don't see how I can load another url in the interceptor, and if I throw an IOException to handle the error later in a Glide RequestListener it will just result in a GlideException so I can't determine why it was throw.</p>