przy użyciu modernizacji z trwałością Cookie
Ja używam retrofit i zastanawiam się, jak przejrzeć pliki cookie sesji. W tym celu rozszerzam podany ApacheClient i używam CookieStore w niestandardowym wywołaniu ApacheClient.execute (HttpClient, HttpUriRequest):
Client client = new ApacheClient() {
final CookieStore cookieStore = new BasicCookieStore();
@Override
protected HttpResponse execute(HttpClient client, HttpUriRequest request) throws IOException {
// BasicHttpContext is not thread safe
// CookieStore is thread safe
BasicHttpContext httpContext = new BasicHttpContext();
httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
return client.execute(request, httpContext);
}
};
RestAdapter restAdapter = new RestAdapter.Builder()
.setServer(API_URL)
.setClient(client)
.build();
Czy jest lepszy sposób, aby to zrobić za pomocą wbudowanego API modernizacji (bez rozszerzenia HttpClient)?