use of okhttp3.RecordingCookieJar in project okhttp by square.
the class CallTest method requestCookies.
@Test
public void requestCookies() throws Exception {
server.enqueue(new MockResponse());
RecordingCookieJar cookieJar = new RecordingCookieJar();
cookieJar.enqueueRequestCookies(new Cookie.Builder().name("a").value("b").domain(server.getHostName()).build(), new Cookie.Builder().name("c").value("d").domain(server.getHostName()).build());
client = client.newBuilder().cookieJar(cookieJar).build();
executeSynchronously("/").assertCode(200);
RecordedRequest recordedRequest = server.takeRequest();
assertEquals("a=b; c=d", recordedRequest.getHeader("Cookie"));
}
Aggregations