public final class OkUrlFactory extends Object implements URLStreamHandlerFactory, Cloneable
| Constructor and Description |
|---|
OkUrlFactory(com.squareup.okhttp.OkHttpClient client) |
| Modifier and Type | Method and Description |
|---|---|
com.squareup.okhttp.OkHttpClient |
client() |
OkUrlFactory |
clone()
Returns a copy of this stream handler factory that includes a shallow copy
of the internal HTTP client.
|
URLStreamHandler |
createURLStreamHandler(String protocol)
Creates a URLStreamHandler as a
URL.setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory). |
HttpURLConnection |
open(URL url) |
public com.squareup.okhttp.OkHttpClient client()
public OkUrlFactory clone()
public HttpURLConnection open(URL url)
public URLStreamHandler createURLStreamHandler(String protocol)
URL.setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory).
This code configures OkHttp to handle all HTTP and HTTPS connections
created with URL.openConnection():
OkHttpClient okHttpClient = new OkHttpClient();
URL.setURLStreamHandlerFactory(new OkUrlFactory(okHttpClient));
createURLStreamHandler in interface URLStreamHandlerFactoryCopyright © 2015 JBoss, a division of Red Hat. All rights reserved.