Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ class TestValueFactory : Closeable {
index = 0,
exchange = null,
request = call.request(),
connectTimeoutMillis = 10_000,
readTimeoutMillis = 10_000,
writeTimeoutMillis = 10_000,
)

fun newRoutePlanner(
Expand Down
36 changes: 33 additions & 3 deletions okhttp/api/android/okhttp.api
Original file line number Diff line number Diff line change
Expand Up @@ -749,12 +749,42 @@ public abstract interface class okhttp3/Interceptor$Chain {
public abstract fun call ()Lokhttp3/Call;
public abstract fun connectTimeoutMillis ()I
public abstract fun connection ()Lokhttp3/Connection;
public abstract fun getAuthenticator ()Lokhttp3/Authenticator;
public abstract fun getCache ()Lokhttp3/Cache;
public abstract fun getCertificatePinner ()Lokhttp3/CertificatePinner;
public abstract fun getConnectionPool ()Lokhttp3/ConnectionPool;
public abstract fun getCookieJar ()Lokhttp3/CookieJar;
public abstract fun getDns ()Lokhttp3/Dns;
public abstract fun getEventListener ()Lokhttp3/EventListener;
public abstract fun getFollowRedirects ()Z
public abstract fun getFollowSslRedirects ()Z
public abstract fun getHostnameVerifier ()Ljavax/net/ssl/HostnameVerifier;
public abstract fun getProxy ()Ljava/net/Proxy;
public abstract fun getProxyAuthenticator ()Lokhttp3/Authenticator;
public abstract fun getProxySelector ()Ljava/net/ProxySelector;
public abstract fun getRetryOnConnectionFailure ()Z
public abstract fun getSocketFactory ()Ljavax/net/SocketFactory;
public abstract fun getSslSocketFactoryOrNull ()Ljavax/net/ssl/SSLSocketFactory;
public abstract fun getX509TrustManagerOrNull ()Ljavax/net/ssl/X509TrustManager;
public abstract fun proceed (Lokhttp3/Request;)Lokhttp3/Response;
public abstract fun readTimeoutMillis ()I
public abstract fun request ()Lokhttp3/Request;
public abstract fun withConnectTimeout (ILjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
public abstract fun withReadTimeout (ILjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
public abstract fun withWriteTimeout (ILjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
public abstract fun withAuthenticator (Lokhttp3/Authenticator;)Lokhttp3/Interceptor$Chain;
public abstract fun withCache (Lokhttp3/Cache;)Lokhttp3/Interceptor$Chain;
public abstract fun withCertificatePinner (Lokhttp3/CertificatePinner;)Lokhttp3/Interceptor$Chain;
public abstract fun withConnectTimeout (JLjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
public abstract fun withConnectionPool (Lokhttp3/ConnectionPool;)Lokhttp3/Interceptor$Chain;
public abstract fun withCookieJar (Lokhttp3/CookieJar;)Lokhttp3/Interceptor$Chain;
public abstract fun withDns (Lokhttp3/Dns;)Lokhttp3/Interceptor$Chain;
public abstract fun withHostnameVerifier (Ljavax/net/ssl/HostnameVerifier;)Lokhttp3/Interceptor$Chain;
public abstract fun withProxy (Ljava/net/Proxy;)Lokhttp3/Interceptor$Chain;
public abstract fun withProxyAuthenticator (Lokhttp3/Authenticator;)Lokhttp3/Interceptor$Chain;
public abstract fun withProxySelector (Ljava/net/ProxySelector;)Lokhttp3/Interceptor$Chain;
public abstract fun withReadTimeout (JLjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
public abstract fun withRetryOnConnectionFailure (Z)Lokhttp3/Interceptor$Chain;
public abstract fun withSocketFactory (Ljavax/net/SocketFactory;)Lokhttp3/Interceptor$Chain;
public abstract fun withSslSocketFactory (Ljavax/net/ssl/SSLSocketFactory;Ljavax/net/ssl/X509TrustManager;)Lokhttp3/Interceptor$Chain;
public abstract fun withWriteTimeout (JLjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
public abstract fun writeTimeoutMillis ()I
}

Expand Down
36 changes: 33 additions & 3 deletions okhttp/api/jvm/okhttp.api
Original file line number Diff line number Diff line change
Expand Up @@ -749,12 +749,42 @@ public abstract interface class okhttp3/Interceptor$Chain {
public abstract fun call ()Lokhttp3/Call;
public abstract fun connectTimeoutMillis ()I
public abstract fun connection ()Lokhttp3/Connection;
public abstract fun getAuthenticator ()Lokhttp3/Authenticator;
public abstract fun getCache ()Lokhttp3/Cache;
public abstract fun getCertificatePinner ()Lokhttp3/CertificatePinner;
public abstract fun getConnectionPool ()Lokhttp3/ConnectionPool;
public abstract fun getCookieJar ()Lokhttp3/CookieJar;
public abstract fun getDns ()Lokhttp3/Dns;
public abstract fun getEventListener ()Lokhttp3/EventListener;
public abstract fun getFollowRedirects ()Z
public abstract fun getFollowSslRedirects ()Z
public abstract fun getHostnameVerifier ()Ljavax/net/ssl/HostnameVerifier;
public abstract fun getProxy ()Ljava/net/Proxy;
public abstract fun getProxyAuthenticator ()Lokhttp3/Authenticator;
public abstract fun getProxySelector ()Ljava/net/ProxySelector;
public abstract fun getRetryOnConnectionFailure ()Z
public abstract fun getSocketFactory ()Ljavax/net/SocketFactory;
public abstract fun getSslSocketFactoryOrNull ()Ljavax/net/ssl/SSLSocketFactory;
public abstract fun getX509TrustManagerOrNull ()Ljavax/net/ssl/X509TrustManager;
public abstract fun proceed (Lokhttp3/Request;)Lokhttp3/Response;
public abstract fun readTimeoutMillis ()I
public abstract fun request ()Lokhttp3/Request;
public abstract fun withConnectTimeout (ILjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
public abstract fun withReadTimeout (ILjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
public abstract fun withWriteTimeout (ILjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
public abstract fun withAuthenticator (Lokhttp3/Authenticator;)Lokhttp3/Interceptor$Chain;
public abstract fun withCache (Lokhttp3/Cache;)Lokhttp3/Interceptor$Chain;
public abstract fun withCertificatePinner (Lokhttp3/CertificatePinner;)Lokhttp3/Interceptor$Chain;
public abstract fun withConnectTimeout (JLjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
public abstract fun withConnectionPool (Lokhttp3/ConnectionPool;)Lokhttp3/Interceptor$Chain;
public abstract fun withCookieJar (Lokhttp3/CookieJar;)Lokhttp3/Interceptor$Chain;
public abstract fun withDns (Lokhttp3/Dns;)Lokhttp3/Interceptor$Chain;
public abstract fun withHostnameVerifier (Ljavax/net/ssl/HostnameVerifier;)Lokhttp3/Interceptor$Chain;
public abstract fun withProxy (Ljava/net/Proxy;)Lokhttp3/Interceptor$Chain;
public abstract fun withProxyAuthenticator (Lokhttp3/Authenticator;)Lokhttp3/Interceptor$Chain;
public abstract fun withProxySelector (Ljava/net/ProxySelector;)Lokhttp3/Interceptor$Chain;
public abstract fun withReadTimeout (JLjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
public abstract fun withRetryOnConnectionFailure (Z)Lokhttp3/Interceptor$Chain;
public abstract fun withSocketFactory (Ljavax/net/SocketFactory;)Lokhttp3/Interceptor$Chain;
public abstract fun withSslSocketFactory (Ljavax/net/ssl/SSLSocketFactory;Ljavax/net/ssl/X509TrustManager;)Lokhttp3/Interceptor$Chain;
public abstract fun withWriteTimeout (JLjava/util/concurrent/TimeUnit;)Lokhttp3/Interceptor$Chain;
public abstract fun writeTimeoutMillis ()I
}

Expand Down
194 changes: 190 additions & 4 deletions okhttp/src/commonJvmAndroid/kotlin/okhttp3/Interceptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
package okhttp3

import java.io.IOException
import java.net.Proxy
import java.net.ProxySelector
import java.util.concurrent.TimeUnit
import javax.net.SocketFactory
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager
import okhttp3.internal.tls.CertificateChainCleaner

/**
* Observes, modifies, and potentially short-circuits requests going out and the corresponding
Expand Down Expand Up @@ -82,31 +89,210 @@ fun interface Interceptor {

/**
* Returns the connection the request will be executed on. This is only available in the chains
* of network interceptors; for application interceptors this is always null.
* of network interceptors. For application interceptors this is always null.
*/
fun connection(): Connection?

/**
* Returns the `Call` to which this chain belongs.
*/
fun call(): Call

/**
* Returns the connect timeout in milliseconds.
*/
fun connectTimeoutMillis(): Int

/**
* Returns a new chain with the specified connect timeout.
*/
fun withConnectTimeout(
timeout: Int,
timeout: Long,
unit: TimeUnit,
): Chain

/**
* Returns the read timeout in milliseconds.
*/
fun readTimeoutMillis(): Int

/**
* Returns a new chain with the specified read timeout.
*/
fun withReadTimeout(
timeout: Int,
timeout: Long,
unit: TimeUnit,
): Chain

/**
* Returns the write timeout in milliseconds.
*/
fun writeTimeoutMillis(): Int

/**
* Returns a new chain with the specified write timeout.
*/
fun withWriteTimeout(
timeout: Int,
timeout: Long,
unit: TimeUnit,
): Chain

val followSslRedirects: Boolean

val followRedirects: Boolean

/**
* Get the [DNS] instance for the OkHttpClient, or an override from the Call.Chain.
*/
val dns: Dns

/**
* Override the [DNS] for the Call.Chain.
*
* @throws IllegalStateException if this is a Network Interceptor, since the override is too late.
*/
fun withDns(dns: Dns): Chain

/**
* Returns the [SocketFactory] for the OkHttpClient, or an override from the Call.Chain.
*/
val socketFactory: SocketFactory

/**
* Override the [SocketFactory] for the Call.Chain.
*
* @throws IllegalStateException if this is a Network Interceptor, since the override is too late.
*/
fun withSocketFactory(socketFactory: SocketFactory): Chain

/**
* Returns true if the call should retry on connection failures.
*/
val retryOnConnectionFailure: Boolean

/**
* Returns a new chain with the specified retry on connection failure setting.
*/
fun withRetryOnConnectionFailure(retryOnConnectionFailure: Boolean): Chain

/**
* Returns the [Authenticator] for the OkHttpClient, or an override from the Call.Chain.
*/
val authenticator: Authenticator

/**
* Override the [Authenticator] for the Call.Chain.
*
* @throws IllegalStateException if this is a Network Interceptor, since the override is too late.
*/
fun withAuthenticator(authenticator: Authenticator): Chain

/**
* Returns the [CookieJar] for the OkHttpClient, or an override from the Call.Chain.
*/
val cookieJar: CookieJar

/**
* Returns a new chain with the specified [CookieJar].
*/
fun withCookieJar(cookieJar: CookieJar): Chain

/**
* Returns the [Cache] for the OkHttpClient, or an override from the Call.Chain.
*/
val cache: Cache?

/**
* Override the [Cache] for the Call.Chain.
*
* @throws IllegalStateException if this is a Network Interceptor, since the override is too late.
*/
fun withCache(cache: Cache?): Chain

/**
* Returns the [Proxy] for the OkHttpClient, or an override from the Call.Chain.
*/
val proxy: Proxy?

/**
* Returns a new chain with the specified [Proxy].
*/
fun withProxy(proxy: Proxy?): Chain

/**
* Returns the [ProxySelector] for the OkHttpClient, or an override from the Call.Chain.
*/
val proxySelector: ProxySelector

/**
* Override the [ProxySelector] for the Call.Chain.
*
* @throws IllegalStateException if this is a Network Interceptor, since the override is too late.
*/
fun withProxySelector(proxySelector: ProxySelector): Chain

/**
* Returns the proxy [Authenticator] for the OkHttpClient, or an override from the Call.Chain.
*/
val proxyAuthenticator: Authenticator

/**
* Returns a new chain with the specified proxy [Authenticator].
*/
fun withProxyAuthenticator(proxyAuthenticator: Authenticator): Chain

/**
* Returns the [SSLSocketFactory] for the OkHttpClient, or an override from the Call.Chain.
*/
val sslSocketFactoryOrNull: SSLSocketFactory?

/**
* Returns a new chain with the specified [SSLSocketFactory].
*
* @throws IllegalStateException if this is a Network Interceptor, since the override is too late.
*/
fun withSslSocketFactory(
sslSocketFactory: SSLSocketFactory?,
x509TrustManager: X509TrustManager?,
): Chain

/**
* Returns the [X509TrustManager] for the OkHttpClient, or an override from the Call.Chain.
*/
val x509TrustManagerOrNull: X509TrustManager?

/**
* Returns the [HostnameVerifier] for the OkHttpClient, or an override from the Call.Chain.
*/
val hostnameVerifier: HostnameVerifier

/**
* Override the [HostnameVerifier] for the Call.Chain.
*
* @throws IllegalStateException if this is a Network Interceptor, since the override is too late.
*/
fun withHostnameVerifier(hostnameVerifier: HostnameVerifier): Chain

/**
* Returns the [CertificatePinner] for the OkHttpClient, or an override from the Call.Chain.
*/
val certificatePinner: CertificatePinner

/**
* Returns a new chain with the specified [CertificatePinner].
*/
fun withCertificatePinner(certificatePinner: CertificatePinner): Chain

/**
* Returns the [ConnectionPool] for the OkHttpClient, or an override from the Call.Chain.
*/
val connectionPool: ConnectionPool

/**
* Returns a new chain with the specified [ConnectionPool].
*/
fun withConnectionPool(connectionPool: ConnectionPool): Chain

val eventListener: EventListener
}
}
2 changes: 1 addition & 1 deletion okhttp/src/commonJvmAndroid/kotlin/okhttp3/OkHttpClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ open class OkHttpClient internal constructor(
@get:JvmName("socketFactory")
val socketFactory: SocketFactory = builder.socketFactory

private val sslSocketFactoryOrNull: SSLSocketFactory?
internal val sslSocketFactoryOrNull: SSLSocketFactory?

@get:JvmName("sslSocketFactory")
val sslSocketFactory: SSLSocketFactory
Expand Down
Loading
Loading