2

I send two request and I want do second request with cookie (cookie from response from first request).

How it work now:

Future<Response> f = asyncHttpClient
    .prepareGet(URL_1)
    .execute();
Response r = f.get();

/* I want code without saving and restoring cookie */
List<Cookie> cookies = r.getCookies();
AsyncHttpClient.BoundRequestBuilder b = asyncHttpClient.prepareGet(URL_2)
for (Cookie c : cookies) {
  b.addCookie(c);
}

f = b.execute();
r = f.get();

I want remove complex code, how can I do it

couatl
  • 416
  • 4
  • 14

1 Answers1

-1

If you are using Java8 already, then ComparableFuture may help you with requests sequential run. Otherwise, you can find useful RxJava third-party (link to RxJava is in the article summary).

Veaceslav Gaidarji
  • 4,261
  • 3
  • 38
  • 61
  • The problem is not the amount of code, problem in logic. I want to asynchttpClient keep cookies if they come in response. – couatl Apr 29 '15 at 13:35
  • ah, ok. then you can check this link: http://stackoverflow.com/questions/15668186/request-doesnt-used-saved-cookies-in-persistentcookiestore. – Veaceslav Gaidarji Apr 29 '15 at 13:57