HttpURLConnection
in an
upcoming release. Applications that need this should either downgrade to the system's built-in
HttpURLConnection
or upgrade to OkHttp's Request/Response API.public final class OkUrlFactory
extends java.lang.Object
implements java.net.URLStreamHandlerFactory, java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
private OkHttpClient |
client
Deprecated.
|
private URLFilter |
urlFilter
Deprecated.
|
Constructor and Description |
---|
OkUrlFactory(OkHttpClient client)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
OkHttpClient |
client()
Deprecated.
|
OkUrlFactory |
clone()
Deprecated.
Returns a copy of this stream handler factory that includes a shallow copy of the internal
HTTP client.
|
java.net.URLStreamHandler |
createURLStreamHandler(java.lang.String protocol)
Deprecated.
Creates a URLStreamHandler as a
URL.setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory) . |
java.net.HttpURLConnection |
open(java.net.URL url)
Deprecated.
|
(package private) java.net.HttpURLConnection |
open(java.net.URL url,
java.net.Proxy proxy)
Deprecated.
|
OkUrlFactory |
setClient(OkHttpClient client)
Deprecated.
|
(package private) void |
setUrlFilter(URLFilter filter)
Deprecated.
|
private OkHttpClient client
private URLFilter urlFilter
public OkUrlFactory(OkHttpClient client)
public OkHttpClient client()
public OkUrlFactory setClient(OkHttpClient client)
void setUrlFilter(URLFilter filter)
public OkUrlFactory clone()
clone
in class java.lang.Object
public java.net.HttpURLConnection open(java.net.URL url)
java.net.HttpURLConnection open(java.net.URL url, java.net.Proxy proxy)
public java.net.URLStreamHandler createURLStreamHandler(java.lang.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 java.net.URLStreamHandlerFactory