Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
all fields
  • Loading branch information
yschimke committed Oct 10, 2025
commit 7abf8eecd68c5105866ab29e5c46e4c5a130aa32
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,7 @@ class TestValueFactory : Closeable {
index = 0,
exchange = null,
request = call.request(),
connectTimeoutMillis = 10_000,
readTimeoutMillis = 10_000,
writeTimeoutMillis = 10_000,
clientOverrides = null,
client = call.client,
)

fun newRoutePlanner(
Expand Down
66 changes: 64 additions & 2 deletions okhttp/src/commonJvmAndroid/kotlin/okhttp3/Interceptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +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 @@ -110,8 +116,64 @@ fun interface Interceptor {
unit: TimeUnit,
): Chain

fun withDns(dns: Dns?): Chain
val dns: Dns
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For provoking discussion, rather than the final set.

The advantage of Call.Decorator was we didn't need to copy all these properties.

we could

  • start out small, and add as each is shown valuable.
  • open all
  • be opinionated based on our ideas

fun withSocketFactory(socketFactory: SocketFactory?): Chain
fun withDns(dns: Dns): Chain

val socketFactory: SocketFactory

fun withSocketFactory(socketFactory: SocketFactory): Chain

val retryOnConnectionFailure: Boolean

fun withRetryOnConnectionFailure(retryOnConnectionFailure: Boolean): Chain

val authenticator: Authenticator

fun withAuthenticator(authenticator: Authenticator): Chain

val cookieJar: CookieJar

fun withCookieJar(cookieJar: CookieJar): Chain

val cache: Cache?

fun withCache(cache: Cache): Chain

val proxy: Proxy?

fun withProxy(proxy: Proxy): Chain

val proxySelector: ProxySelector

fun withProxySelector(proxySelector: ProxySelector): Chain

val proxyAuthenticator: Authenticator

fun withProxyAuthenticator(proxyAuthenticator: Authenticator): Chain

val sslSocketFactory: SSLSocketFactory

fun withSslSocketFactory(sslSocketFactory: SSLSocketFactory): Chain

val x509TrustManager: X509TrustManager?

fun withX509TrustManager(x509TrustManager: X509TrustManager): Chain

val hostnameVerifier: HostnameVerifier

fun withHostnameVerifier(hostnameVerifier: HostnameVerifier): Chain

val certificatePinner: CertificatePinner

fun withCertificatePinner(certificatePinner: CertificatePinner): Chain

val certificateChainCleaner: CertificateChainCleaner?

fun withCertificateChainCleaner(certificateChainCleaner: CertificateChainCleaner): Chain

val connectionPool: ConnectionPool

fun withConnectionPool(connectionPool: ConnectionPool): Chain
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we throw if you call this on a network interceptor, since you’re already connected?

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,7 @@ class RealCall(
index = 0,
exchange = null,
request = originalRequest,
connectTimeoutMillis = client.connectTimeoutMillis,
readTimeoutMillis = client.readTimeoutMillis,
writeTimeoutMillis = client.writeTimeoutMillis,
clientOverrides = null,
client = client,
)

var calledNoMoreExchanges = false
Expand Down Expand Up @@ -257,7 +254,7 @@ class RealCall(
pingIntervalMillis = client.pingIntervalMillis,
retryOnConnectionFailure = client.retryOnConnectionFailure,
fastFallback = client.fastFallback,
address = client.address(request.url),
address = chain.address(request.url),
routeDatabase = client.routeDatabase,
call = this,
request = request,
Expand Down
Loading
Loading