public final class ObsoleteUrlFactory extends Object implements URLStreamHandlerFactory, Cloneable
Rather than pasting this 1100 line gist into your source code, please upgrade to OkHttp's request/response API. Your code will be shorter, easier to read, and you'll be able to use interceptors.
| Constructor and Description |
|---|
ObsoleteUrlFactory(okhttp3.OkHttpClient client)
Instantiates a new Obsolete url factory.
|
| Modifier and Type | Method and Description |
|---|---|
okhttp3.OkHttpClient |
client()
Client ok http client.
|
ObsoleteUrlFactory |
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)
Open http url connection.
|
ObsoleteUrlFactory |
setClient(okhttp3.OkHttpClient client)
Sets client.
|
public ObsoleteUrlFactory(okhttp3.OkHttpClient client)
client - the clientpublic okhttp3.OkHttpClient client()
public ObsoleteUrlFactory setClient(okhttp3.OkHttpClient client)
client - the clientpublic ObsoleteUrlFactory clone()
public HttpURLConnection open(URL url)
url - the urlpublic URLStreamHandler createURLStreamHandler(String protocol)
URL.setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory).
This code configures OkHttp to handle all HTTP and HTTPS connections created with
URL.openConnection():
{
@code
OkHttpClient okHttpClient = new OkHttpClient();
URL.setURLStreamHandlerFactory(new ObsoleteUrlFactory(okHttpClient));
}
createURLStreamHandler in interface URLStreamHandlerFactoryCopyright © 2020. All rights reserved.