public void run() throws Exception { File socketFile = new File("/tmp/ClientAndServer.sock"); socketFile.delete(); // Clean up from previous runs. MockWebServer server = new MockWebServer(); server.setServerSocketFactory(new UnixDomainServerSocketFactory(socketFile)); server.setProtocols(Collections.singletonList(Protocol.H2_PRIOR_KNOWLEDGE)); server.enqueue(new MockResponse().setBody("hello")); server.start(); OkHttpClient client = new OkHttpClient.Builder() .socketFactory(new UnixDomainSocketFactory(socketFile)) .protocols(Collections.singletonList(Protocol.H2_PRIOR_KNOWLEDGE)) .build(); Request request = new Request.Builder() .url("http://publicobject.com/helloworld.txt") .build(); try (Response response = client.newCall(request).execute()) { System.out.println(response.body().string()); } server.shutdown(); socketFile.delete(); }
builder.socketFactory(new SocketChannelSocketFactory());
okHttpClientBuilder.sslSocketFactory(sslSocketFactory, x509TrustManager); if (setAsSocketFactory) { okHttpClientBuilder.socketFactory(sslSocketFactory);
okHttpClientBuilder.sslSocketFactory(sslSocketFactory, x509TrustManager); if (setAsSocketFactory) { okHttpClientBuilder.socketFactory(sslSocketFactory);
builder.socketFactory(new SocketChannelSocketFactory());
builder.socketFactory(new SocketChannelSocketFactory());
builder.socketFactory(new SocketChannelSocketFactory());
return builder.socketFactory(sockProxySocketFactory); } else if (main.getProxyType() == ProxyType.HTTP) { builder = builder.proxy(new Proxy(Type.HTTP, new InetSocketAddress(main.getProxyHost(), main.getProxyPort()))).proxyAuthenticator((Route route, Response response) -> {
private void onHttpCertficates(int[] certficates, String[] hosts) { mBuilder.socketFactory(ClientHelper.getSSLSocketFactory(AppContext.context(), certficates)); mBuilder.hostnameVerifier(ClientHelper.getHostnameVerifier(hosts)); }
public static OkHttpClient.Builder getSafeClientBuilder() { if (sDelegatingSocketFactory == null) { sDelegatingSocketFactory = new DelegatingSocketFactory(SocketFactory.getDefault()); } return new OkHttpClient.Builder() .connectionSpecs(createConnectionSpecs()) .socketFactory(sDelegatingSocketFactory); }
public static OkHttpClient.Builder getSafeClientBuilder() { if (sDelegatingSocketFactory == null) { sDelegatingSocketFactory = new DelegatingSocketFactory(SocketFactory.getDefault()); } return new OkHttpClient.Builder() .connectionSpecs(createConnectionSpecs(ConnectionSpec.RESTRICTED_TLS, false)) .socketFactory(sDelegatingSocketFactory); }
/** * * @param socketFactory * @return */ public FastHttpClientBuilder socketFactory(SocketFactory socketFactory) { builder.socketFactory(socketFactory); return this; }
private void onHttpCertficates(int[] certficates, String[] hosts) { mBuilder.socketFactory(ClientHelper.getSSLSocketFactory(AppContext.context(), certficates)); mBuilder.hostnameVerifier(ClientHelper.getHostnameVerifier(hosts)); }
@Provides @Singleton public Call.Factory provideCallFactory(Context context) { return new OkHttpClient.Builder() .socketFactory(new SocketFactory() { private SocketFactory mDefaultFactory = SocketFactory.getDefault();
.socketFactory(new UnixSocketFactory(socketPath)); } else { clientBuilder .socketFactory(new NamedPipeSocketFactory(socketPath));