use of okhttp3.internal.DoubleInetAddressDns in project okhttp by square.
the class HttpOverHttp2Test method recoverFromOneInternalErrorRequiresNewConnection.
@Test
public void recoverFromOneInternalErrorRequiresNewConnection() throws Exception {
server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.RESET_STREAM_AT_START).setHttp2ErrorCode(ErrorCode.INTERNAL_ERROR.httpCode));
server.enqueue(new MockResponse().setBody("abc"));
client = client.newBuilder().dns(new DoubleInetAddressDns()).build();
Call call = client.newCall(new Request.Builder().url(server.url("/")).build());
Response response = call.execute();
assertEquals("abc", response.body().string());
// New connection.
assertEquals(0, server.takeRequest().getSequenceNumber());
// New connection.
assertEquals(0, server.takeRequest().getSequenceNumber());
}
use of okhttp3.internal.DoubleInetAddressDns in project okhttp by square.
the class URLConnectionTest method streamedBodyIsNotRetried.
@Test
public void streamedBodyIsNotRetried() throws Exception {
server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.DISCONNECT_AFTER_REQUEST));
urlFactory = new OkUrlFactory(defaultClient().newBuilder().dns(new DoubleInetAddressDns()).build());
HttpURLConnection connection = urlFactory.open(server.url("/").url());
connection.setDoOutput(true);
connection.setChunkedStreamingMode(100);
OutputStream os = connection.getOutputStream();
os.write("OutputStream is no fun.".getBytes("UTF-8"));
os.close();
try {
connection.getResponseCode();
fail();
} catch (IOException expected) {
}
assertEquals(1, server.getRequestCount());
}
use of okhttp3.internal.DoubleInetAddressDns in project okhttp by square.
the class CallTest method recoverWhenRetryOnConnectionFailureIsTrue.
@Test
public void recoverWhenRetryOnConnectionFailureIsTrue() throws Exception {
server.enqueue(new MockResponse().setBody("seed connection pool"));
server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.DISCONNECT_AFTER_REQUEST));
server.enqueue(new MockResponse().setBody("retry success"));
client = client.newBuilder().dns(new DoubleInetAddressDns()).build();
assertTrue(client.retryOnConnectionFailure());
executeSynchronously("/").assertBody("seed connection pool");
executeSynchronously("/").assertBody("retry success");
}
use of okhttp3.internal.DoubleInetAddressDns in project okhttp by square.
the class HttpOverHttp2Test method recoverFromMultipleRefusedStreamsRequiresNewConnection.
@Test
public void recoverFromMultipleRefusedStreamsRequiresNewConnection() throws Exception {
server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.RESET_STREAM_AT_START).setHttp2ErrorCode(ErrorCode.REFUSED_STREAM.httpCode));
server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.RESET_STREAM_AT_START).setHttp2ErrorCode(ErrorCode.REFUSED_STREAM.httpCode));
server.enqueue(new MockResponse().setBody("abc"));
client = client.newBuilder().dns(new DoubleInetAddressDns()).build();
Call call = client.newCall(new Request.Builder().url(server.url("/")).build());
Response response = call.execute();
assertEquals("abc", response.body().string());
// New connection.
assertEquals(0, server.takeRequest().getSequenceNumber());
// Reused connection.
assertEquals(1, server.takeRequest().getSequenceNumber());
// New connection.
assertEquals(0, server.takeRequest().getSequenceNumber());
}
Aggregations