Synchronized (HttpUtil. Class) {
If (singleton==null) {
The singleton=new OkHttpClient. Builder ()
ConnectTimeout (10, TimeUnit. SECONDS)
ReadTimeout (20, TimeUnit. SECONDS)
AddInterceptor (new LoggingInterceptor ())
CookieJar (new cookieJar () {
Private final HashMap
@ Override
Public void saveFromResponse (HttpUrl url, List
CookieStore. Put (url. Host (), cookies);
}
@ Override
Public List
List
System. The out. Println (" Cookies======="+ Cookies);
Return the cookies!=null? Cookies: new ArrayList
}
}). The build ();
}
}
}
The debug code to run to the cookieStore. Get (url. The host ()) has a value, code to run to cookieStore. Put (url. Host (), cookies); The cookie value is missing, advice on how to deal with?
CodePudding user response:
Make sure the server returns a response whether contains cookiesCodePudding user response: