List of usage examples for com.squareup.okhttp OkHttpClient getConnectionPool
public ConnectionPool getConnectionPool()
From source file:twitter4j.SpdyHttpClientTest.java
License:Apache License
public void testSpdy() throws Exception { AlternativeHttpClientImpl.sPreferSpdy = true; AlternativeHttpClientImpl.sPreferHttp2 = false; AlternativeHttpClientImpl http = callOembed(); // check SPDY Field f = http.getClass().getDeclaredField("client"); f.setAccessible(true);//from w w w . java2 s . c om OkHttpClient client = (OkHttpClient) f.get(http); assertNotNull("ensure that OkHttpClient is used", client); ConnectionPool p = client.getConnectionPool(); assertEquals(1, p.getConnectionCount()); assertEquals(0, p.getHttpConnectionCount()); assertEquals(1, p.getSpdyConnectionCount()); assertEquals("spdy/3.1", http.getLastRequestProtocol()); }
From source file:twitter4j.SpdyHttpClientTest.java
License:Apache License
public void testHttp2() throws Exception { AlternativeHttpClientImpl.sPreferSpdy = false; AlternativeHttpClientImpl.sPreferHttp2 = true; AlternativeHttpClientImpl http = callOembed(); // check HTTP/2.0 Field f = http.getClass().getDeclaredField("client"); f.setAccessible(true);//from w ww . j a va 2 s .c o m OkHttpClient client = (OkHttpClient) f.get(http); assertNotNull("ensure that OkHttpClient is used", client); ConnectionPool p = client.getConnectionPool(); assertEquals(1, p.getConnectionCount()); assertEquals(0, p.getHttpConnectionCount()); assertEquals(1, p.getSpdyConnectionCount()); assertEquals("HTTP-draft-09/2.0", http.getLastRequestProtocol()); }