Package com.squareup.okhttp
Class OkUrlFactory
- java.lang.Object
-
- com.squareup.okhttp.OkUrlFactory
-
- All Implemented Interfaces:
Cloneable,URLStreamHandlerFactory
public final class OkUrlFactory extends Object implements URLStreamHandlerFactory, Cloneable
-
-
Constructor Summary
Constructors Constructor Description OkUrlFactory(OkHttpClient client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OkHttpClientclient()OkUrlFactoryclone()Returns a copy of this stream handler factory that includes a shallow copy of the internal HTTP client.URLStreamHandlercreateURLStreamHandler(String protocol)Creates a URLStreamHandler as aURL.setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory).HttpURLConnectionopen(URL url)
-
-
-
Constructor Detail
-
OkUrlFactory
public OkUrlFactory(OkHttpClient client)
-
-
Method Detail
-
client
public OkHttpClient client()
-
clone
public OkUrlFactory clone()
Returns a copy of this stream handler factory that includes a shallow copy of the internal HTTP client.
-
open
public HttpURLConnection open(URL url)
-
createURLStreamHandler
public URLStreamHandler createURLStreamHandler(String protocol)
Creates a URLStreamHandler as aURL.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));- Specified by:
createURLStreamHandlerin interfaceURLStreamHandlerFactory- Parameters:
protocol- the protocol for which a handler is needed.- Returns:
- the created handler.
-
-