2

I can use OkhttpClient to send a GET request to the server and get the cookie in the final response properly(the response code of which is 200 )and the cookie of which can be retrieved using addInterceptor().

Request-> 302(Set-cookie?) -> 302(Set-cookie?) -> 302(Set-cookie?) ->200(Set-cookie√(can be get using interceptor))

(the question mark ? means don't know how to get)

But the situation here is that there might be a series of redirects before the final response(200) is returned, the redirects carry the Set-cookie header. Is there any way using Okhttp to retrieve the cookies in the Set-cookie header in every redirect?

kolibreath
  • 125
  • 2
  • 13
  • Did you ever solve this problem? – iOSAddicted Feb 14 '18 at 17:34
  • @iOSAddicted sorry no. I used another way to solve the problem. I have a thought with practise that I can use ``followRedirect(false)`` method to stop each redirect by adding the method to several ``OkhttpClient``s,those clients share the same ``CookieJar``. – kolibreath Feb 15 '18 at 02:06
  • @iOSAddicted BTW, I posted the question mainly because I came across the ``too many follow-up`` exception. I successfully dealt with the exception by implementing ``loadForRequest()`` matching different urls with their cookies in the request header. – kolibreath Feb 15 '18 at 02:08

0 Answers0