private void setupClient(int count, boolean h2) throws Exception { clients = IntStream.range(0, count) .mapToObj( index -> { try { if (h2) { return OkHttpUnsafe.getUnsafeClient() .newBuilder() .protocols(Arrays.asList(HTTP_2, HTTP_1_1)) .build(); } else { return OkHttpUnsafe.getUnsafeClient() .newBuilder() .protocols(Collections.singletonList(HTTP_1_1)) .build(); } } catch (Exception e) { return null; } }) .collect(Collectors.toList()); }
/** * Make a synchronous https request using an unsafe http client. * * @param address the request address. * @param protocols the protocol(s) to support. * @return a response. */ public static Response https(InetSocketAddress address, Protocol... protocols) throws Exception { String url = buildUrl("https://", address); return request(url, OkHttpUnsafe.getUnsafeClient(protocols)); } }
@Before public void setUp() throws Exception { log.debug("Test: " + testName.getMethodName()); client = OkHttpUnsafe.getUnsafeClient() .newBuilder() .protocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1)) .build(); TlsConfig tlsConfig = TlsConfig.builderFrom(ConfigFactory.load().getConfig("xio.h2BackendServer.settings.tls")) .build(); server = OkHttpUnsafe.getSslMockWebServer(getKeyManagers(tlsConfig)); server.setProtocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1)); server.start(); }
@Before public void setUp() throws Exception { TlsConfig tlsConfig = TlsConfig.builderFrom(ConfigFactory.load().getConfig("xio.testServer.settings.tls")) .build(); client = OkHttpUnsafe.getUnsafeClient(); server = OkHttpUnsafe.getSslMockWebServer(getKeyManagers(tlsConfig)); server.start(); }