title: Retrofit2 How to get redirect url @HEAD("/")
body: <p>I have a minified URL and I want to have the final URL </p>
  
  <p>With Retrofit 1.9 I used to do this :</p>
  
  <pre><code>@HEAD("/XXXXXXXXX")
  void fetchFinalUrl(Callback&lt;String&gt; cb);
  
  
  public void getUrl() {
     mMinifyService.fetchFinalUrl(new Callback&lt;String&gt;() {
                  @Override
                  public void success(String s, Response response) {
                      response.getUrl();
                  }
                  [...]
  }
  </code></pre>
  
  <p>But now with Retrofit 2 .getUrl() not exist any ideas how to do this?</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Finally got it!</p>
  
  <pre><code>public class ApiProvider&lt;T&gt; {
  
      private Retrofit retrofit;
      private static final String END_POINT_MINIFY = "XXXXXXX";
  
      public ApiProvider() {
          initAdapter();
      }
  
      public T getService(Class&lt;T&gt; service) {
          return retrofit.create(service);
      }
  
      private void initAdapter() {
          HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
          interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
          OkHttpClient client = new OkHttpClient.Builder()
                  .addInterceptor(interceptor)
                  .followRedirects(false)
                  .build();
  
          retrofit = new Retrofit.Builder()
                  .baseUrl(END_POINT_MINIFY)
                  .addConverterFactory(new ToStringConverterFactory())
                  .client(client)
                  .build();
      }
  
  }
  
  public interface IMinifyService {
      @HEAD("/XXXXXXXXX")
      Call&lt;Void&gt; fetchFinalUrl(Callback&lt;String&gt; cb);
  }
  
  
  public class MinifyServiceImpl {
  
      private ApiProvider&lt;IMinifyService&gt; mApiProvider = new ApiProvider&lt;&gt;();
      private IMinifyService mMinifyService = mApiProvider.getService(IMinifyService.class);
  
      public Promiser&lt;String, Integer&gt; fetchMinifyUrl() {
          return new Promiser&lt;&gt;((resolve, reject) -&gt; mMinifyService.fetchMinifyUrl().enqueue(new Callback&lt;Void&gt;() {
              @Override
              public void onResponse(Call&lt;Void&gt; call, Response&lt;Void&gt; response) {
                  if (response.code() &gt;= 300 &amp;&amp; response.code() &lt; 400){
                      resole.run(response.headers().get("Location"));
                  } else {
                      reject.run(response.code());
                  }
              }
  
              @Override
              public void onFailure(Call&lt;Void&gt; call, Throwable t) {
                  reject.run(t.hashCode());
              }
          }));
      }
  
  }
  </code></pre>
  
  <p>if you want to use Promizer --> <a href="https://github.com/NodensN/android-promiser" rel="nofollow">Click here</a></p>