How do you prevent Retrofit from automatically following a 302

前端 未结 5 1397
忘了有多久
忘了有多久 2021-02-18 23:43

I have an authentication call that i\'m trying to make using Retrofit on Android. The call returns a 302 to either a success or failure page. The original 302 response brings ba

5条回答
  •  -上瘾入骨i
    2021-02-19 00:31

    I've edited my previous answer since you're most likely using a POST/PUT when calling your login rest api and OkHttp converts any non GET or HEAD request into a GET request before redirecting which would probably not work for you.

    Currently the feature of disabling redirects is missing from OkHttp but I've submitted a pull request for it. If and when that pull request is accepted it should allow you to disable redirect giving you the opportunity to deal with this use case on your own for the time being.

    Here's the pull request https://github.com/square/okhttp/pull/944

提交回复
热议问题