Http Status Code in Android Volley when error.networkResponse is null

前端 未结 8 1139
忘了有多久
忘了有多久 2020-11-29 00:44

I am using Google Volley on the Android platform. I am having a problem in which the error parameter in onErrorResponse is returning a null n

8条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 00:53

    Volley supports HTTP 401 Unauthorized response. But this response MUST include "WWW-Authenticate" header field.

    Without this header, 401 response causes "com.android.volley.NoConnectionError: java.io.IOException: No authentication challenges found" error.

    For more detail : https://stackoverflow.com/a/25556453/860189

    If you consume 3rd party API's and have no right to change response header, you may consider to implement your own HttpStack because of this exception thrown from HurlStack. Or better, use OkHttpStack as a HttpStack.

提交回复
热议问题