Giter Site home page Giter Site logo

Retry Request about fast-android-networking HOT 4 CLOSED

hank08 avatar hank08 commented on April 28, 2024
Retry Request

from fast-android-networking.

Comments (4)

amitshekhariitbhu avatar amitshekhariitbhu commented on April 28, 2024

@hank08 : This link may help http://stackoverflow.com/questions/24562716/how-to-retry-http-requests-with-okhttp-retrofit

from fast-android-networking.

hank08 avatar hank08 commented on April 28, 2024

Thanks for the speedy response! I had found a similar link and implemented it as follows.
However when the authetication error is called the onError(ANError anError) method gets triggered and then the onResponse is never called. I would have assumed that the returned response would be what gets read and interpreted to determine whether it succeded or not. So I guess my real question is why doesn't my AFN.onResponse method get fired?

 public Response intercept(Chain chain) throws IOException {
                        Request request = chain.request();
                        request = request.newBuilder()
                                .addHeader("cookie", getAuthentication(context))
                                .build();
                        Response response = chain.proceed(request);
                        if(!response.isSuccessful() && response.code() == 401){
                            Log.d("OKHTTP","401 error unauthenticated");
                            OsiiAccountManager.logout(context, getAuthentication(context),null);
                            Request newRequest = chain.request();
                            newRequest = newRequest.newBuilder()
                                    .addHeader("cookie", getAuthentication(context))
                                    .build();
                            response = chain.proceed(newRequest);
                        }
                        return response;
                    }

from fast-android-networking.

amitshekhariitbhu avatar amitshekhariitbhu commented on April 28, 2024

Will check it and inform u

from fast-android-networking.

hank08 avatar hank08 commented on April 28, 2024

Sorry, I was having a race condition that was resulting in the authentication invalidating itself after it had gotten a new token. It is working correctly now.

from fast-android-networking.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.