|
16 | 16 | package okhttp3 |
17 | 17 |
|
18 | 18 | import java.io.IOException |
| 19 | +import java.net.Proxy |
| 20 | +import java.net.ProxySelector |
19 | 21 | import java.util.concurrent.TimeUnit |
| 22 | +import javax.net.SocketFactory |
| 23 | +import javax.net.ssl.HostnameVerifier |
| 24 | +import javax.net.ssl.SSLSocketFactory |
| 25 | +import javax.net.ssl.X509TrustManager |
| 26 | +import okhttp3.internal.tls.CertificateChainCleaner |
20 | 27 |
|
21 | 28 | /** |
22 | 29 | * Observes, modifies, and potentially short-circuits requests going out and the corresponding |
@@ -82,31 +89,210 @@ fun interface Interceptor { |
82 | 89 |
|
83 | 90 | /** |
84 | 91 | * Returns the connection the request will be executed on. This is only available in the chains |
85 | | - * of network interceptors; for application interceptors this is always null. |
| 92 | + * of network interceptors. For application interceptors this is always null. |
86 | 93 | */ |
87 | 94 | fun connection(): Connection? |
88 | 95 |
|
| 96 | + /** |
| 97 | + * Returns the `Call` to which this chain belongs. |
| 98 | + */ |
89 | 99 | fun call(): Call |
90 | 100 |
|
| 101 | + /** |
| 102 | + * Returns the connect timeout in milliseconds. |
| 103 | + */ |
91 | 104 | fun connectTimeoutMillis(): Int |
92 | 105 |
|
| 106 | + /** |
| 107 | + * Returns a new chain with the specified connect timeout. |
| 108 | + */ |
93 | 109 | fun withConnectTimeout( |
94 | | - timeout: Int, |
| 110 | + timeout: Long, |
95 | 111 | unit: TimeUnit, |
96 | 112 | ): Chain |
97 | 113 |
|
| 114 | + /** |
| 115 | + * Returns the read timeout in milliseconds. |
| 116 | + */ |
98 | 117 | fun readTimeoutMillis(): Int |
99 | 118 |
|
| 119 | + /** |
| 120 | + * Returns a new chain with the specified read timeout. |
| 121 | + */ |
100 | 122 | fun withReadTimeout( |
101 | | - timeout: Int, |
| 123 | + timeout: Long, |
102 | 124 | unit: TimeUnit, |
103 | 125 | ): Chain |
104 | 126 |
|
| 127 | + /** |
| 128 | + * Returns the write timeout in milliseconds. |
| 129 | + */ |
105 | 130 | fun writeTimeoutMillis(): Int |
106 | 131 |
|
| 132 | + /** |
| 133 | + * Returns a new chain with the specified write timeout. |
| 134 | + */ |
107 | 135 | fun withWriteTimeout( |
108 | | - timeout: Int, |
| 136 | + timeout: Long, |
109 | 137 | unit: TimeUnit, |
110 | 138 | ): Chain |
| 139 | + |
| 140 | + val followSslRedirects: Boolean |
| 141 | + |
| 142 | + val followRedirects: Boolean |
| 143 | + |
| 144 | + /** |
| 145 | + * Get the [DNS] instance for the OkHttpClient, or an override from the Call.Chain. |
| 146 | + */ |
| 147 | + val dns: Dns |
| 148 | + |
| 149 | + /** |
| 150 | + * Override the [DNS] for the Call.Chain. |
| 151 | + * |
| 152 | + * @throws IllegalStateException if this is a Network Interceptor, since the override is too late. |
| 153 | + */ |
| 154 | + fun withDns(dns: Dns): Chain |
| 155 | + |
| 156 | + /** |
| 157 | + * Returns the [SocketFactory] for the OkHttpClient, or an override from the Call.Chain. |
| 158 | + */ |
| 159 | + val socketFactory: SocketFactory |
| 160 | + |
| 161 | + /** |
| 162 | + * Override the [SocketFactory] for the Call.Chain. |
| 163 | + * |
| 164 | + * @throws IllegalStateException if this is a Network Interceptor, since the override is too late. |
| 165 | + */ |
| 166 | + fun withSocketFactory(socketFactory: SocketFactory): Chain |
| 167 | + |
| 168 | + /** |
| 169 | + * Returns true if the call should retry on connection failures. |
| 170 | + */ |
| 171 | + val retryOnConnectionFailure: Boolean |
| 172 | + |
| 173 | + /** |
| 174 | + * Returns a new chain with the specified retry on connection failure setting. |
| 175 | + */ |
| 176 | + fun withRetryOnConnectionFailure(retryOnConnectionFailure: Boolean): Chain |
| 177 | + |
| 178 | + /** |
| 179 | + * Returns the [Authenticator] for the OkHttpClient, or an override from the Call.Chain. |
| 180 | + */ |
| 181 | + val authenticator: Authenticator |
| 182 | + |
| 183 | + /** |
| 184 | + * Override the [Authenticator] for the Call.Chain. |
| 185 | + * |
| 186 | + * @throws IllegalStateException if this is a Network Interceptor, since the override is too late. |
| 187 | + */ |
| 188 | + fun withAuthenticator(authenticator: Authenticator): Chain |
| 189 | + |
| 190 | + /** |
| 191 | + * Returns the [CookieJar] for the OkHttpClient, or an override from the Call.Chain. |
| 192 | + */ |
| 193 | + val cookieJar: CookieJar |
| 194 | + |
| 195 | + /** |
| 196 | + * Returns a new chain with the specified [CookieJar]. |
| 197 | + */ |
| 198 | + fun withCookieJar(cookieJar: CookieJar): Chain |
| 199 | + |
| 200 | + /** |
| 201 | + * Returns the [Cache] for the OkHttpClient, or an override from the Call.Chain. |
| 202 | + */ |
| 203 | + val cache: Cache? |
| 204 | + |
| 205 | + /** |
| 206 | + * Override the [Cache] for the Call.Chain. |
| 207 | + * |
| 208 | + * @throws IllegalStateException if this is a Network Interceptor, since the override is too late. |
| 209 | + */ |
| 210 | + fun withCache(cache: Cache?): Chain |
| 211 | + |
| 212 | + /** |
| 213 | + * Returns the [Proxy] for the OkHttpClient, or an override from the Call.Chain. |
| 214 | + */ |
| 215 | + val proxy: Proxy? |
| 216 | + |
| 217 | + /** |
| 218 | + * Returns a new chain with the specified [Proxy]. |
| 219 | + */ |
| 220 | + fun withProxy(proxy: Proxy?): Chain |
| 221 | + |
| 222 | + /** |
| 223 | + * Returns the [ProxySelector] for the OkHttpClient, or an override from the Call.Chain. |
| 224 | + */ |
| 225 | + val proxySelector: ProxySelector |
| 226 | + |
| 227 | + /** |
| 228 | + * Override the [ProxySelector] for the Call.Chain. |
| 229 | + * |
| 230 | + * @throws IllegalStateException if this is a Network Interceptor, since the override is too late. |
| 231 | + */ |
| 232 | + fun withProxySelector(proxySelector: ProxySelector): Chain |
| 233 | + |
| 234 | + /** |
| 235 | + * Returns the proxy [Authenticator] for the OkHttpClient, or an override from the Call.Chain. |
| 236 | + */ |
| 237 | + val proxyAuthenticator: Authenticator |
| 238 | + |
| 239 | + /** |
| 240 | + * Returns a new chain with the specified proxy [Authenticator]. |
| 241 | + */ |
| 242 | + fun withProxyAuthenticator(proxyAuthenticator: Authenticator): Chain |
| 243 | + |
| 244 | + /** |
| 245 | + * Returns the [SSLSocketFactory] for the OkHttpClient, or an override from the Call.Chain. |
| 246 | + */ |
| 247 | + val sslSocketFactoryOrNull: SSLSocketFactory? |
| 248 | + |
| 249 | + /** |
| 250 | + * Returns a new chain with the specified [SSLSocketFactory]. |
| 251 | + * |
| 252 | + * @throws IllegalStateException if this is a Network Interceptor, since the override is too late. |
| 253 | + */ |
| 254 | + fun withSslSocketFactory( |
| 255 | + sslSocketFactory: SSLSocketFactory?, |
| 256 | + x509TrustManager: X509TrustManager?, |
| 257 | + ): Chain |
| 258 | + |
| 259 | + /** |
| 260 | + * Returns the [X509TrustManager] for the OkHttpClient, or an override from the Call.Chain. |
| 261 | + */ |
| 262 | + val x509TrustManagerOrNull: X509TrustManager? |
| 263 | + |
| 264 | + /** |
| 265 | + * Returns the [HostnameVerifier] for the OkHttpClient, or an override from the Call.Chain. |
| 266 | + */ |
| 267 | + val hostnameVerifier: HostnameVerifier |
| 268 | + |
| 269 | + /** |
| 270 | + * Override the [HostnameVerifier] for the Call.Chain. |
| 271 | + * |
| 272 | + * @throws IllegalStateException if this is a Network Interceptor, since the override is too late. |
| 273 | + */ |
| 274 | + fun withHostnameVerifier(hostnameVerifier: HostnameVerifier): Chain |
| 275 | + |
| 276 | + /** |
| 277 | + * Returns the [CertificatePinner] for the OkHttpClient, or an override from the Call.Chain. |
| 278 | + */ |
| 279 | + val certificatePinner: CertificatePinner |
| 280 | + |
| 281 | + /** |
| 282 | + * Returns a new chain with the specified [CertificatePinner]. |
| 283 | + */ |
| 284 | + fun withCertificatePinner(certificatePinner: CertificatePinner): Chain |
| 285 | + |
| 286 | + /** |
| 287 | + * Returns the [ConnectionPool] for the OkHttpClient, or an override from the Call.Chain. |
| 288 | + */ |
| 289 | + val connectionPool: ConnectionPool |
| 290 | + |
| 291 | + /** |
| 292 | + * Returns a new chain with the specified [ConnectionPool]. |
| 293 | + */ |
| 294 | + fun withConnectionPool(connectionPool: ConnectionPool): Chain |
| 295 | + |
| 296 | + val eventListener: EventListener |
111 | 297 | } |
112 | 298 | } |
0 commit comments