Search in sources :

Example 11 with Header

use of retrofit2.http.Header in project Varis-Android by dkhmelenko.

the class AuthPresenter method isTwoFactorAuthRequired.

private boolean isTwoFactorAuthRequired(HttpException exception) {
    Response response = exception.response();
    boolean twoFactorAuthRequired = false;
    for (String header : response.headers().names()) {
        if (GithubApiService.TWO_FACTOR_HEADER.equals(header)) {
            twoFactorAuthRequired = true;
            break;
        }
    }
    return response.code() == HttpURLConnection.HTTP_UNAUTHORIZED && twoFactorAuthRequired;
}
Also used : Response(retrofit2.Response)

Aggregations

Request (okhttp3.Request)7 ResponseBody (okhttp3.ResponseBody)6 Test (org.junit.Test)6 Header (retrofit2.http.Header)6 OkHttpClient (okhttp3.OkHttpClient)3 Retrofit (retrofit2.Retrofit)3 MultipartBody (okhttp3.MultipartBody)2 RequestBody (okhttp3.RequestBody)2 Response (retrofit2.Response)2 Body (retrofit2.http.Body)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HttpHeaders (com.google.common.net.HttpHeaders)1 MediaType (com.google.common.net.MediaType)1 NonNull (io.reactivex.annotations.NonNull)1 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 Disposable (io.reactivex.disposables.Disposable)1 Function (io.reactivex.functions.Function)1 IOException (java.io.IOException)1 BigInteger (java.math.BigInteger)1 List (java.util.List)1