Skip to content
Merged
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
3 changes: 3 additions & 0 deletions okhttp/src/commonJvmAndroid/kotlin/okhttp3/ConnectionPool.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:OptIn(OkHttpInternalApi::class)

package okhttp3

import java.util.concurrent.TimeUnit
import okhttp3.internal.OkHttpInternalApi
import okhttp3.internal.concurrent.TaskRunner
import okhttp3.internal.connection.ConnectionListener
import okhttp3.internal.connection.RealConnectionPool
Expand Down
3 changes: 3 additions & 0 deletions okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:OptIn(OkHttpInternalApi::class)

package okhttp3

import java.util.ArrayDeque
import java.util.concurrent.ExecutorService
import java.util.concurrent.SynchronousQueue
import java.util.concurrent.ThreadPoolExecutor
import java.util.concurrent.TimeUnit
import okhttp3.internal.OkHttpInternalApi
import okhttp3.internal.assertLockNotHeld
import okhttp3.internal.connection.RealCall
import okhttp3.internal.connection.RealCall.AsyncCall
Expand Down
3 changes: 3 additions & 0 deletions okhttp/src/commonJvmAndroid/kotlin/okhttp3/OkHttpClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:OptIn(OkHttpInternalApi::class)

package okhttp3

import java.net.Proxy
Expand All @@ -30,6 +32,7 @@ import javax.net.ssl.X509TrustManager
import kotlin.time.Duration as KotlinDuration
import okhttp3.Protocol.HTTP_1_1
import okhttp3.Protocol.HTTP_2
import okhttp3.internal.OkHttpInternalApi
import okhttp3.internal.asFactory
import okhttp3.internal.checkDuration
import okhttp3.internal.concurrent.TaskRunner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:OptIn(OkHttpInternalApi::class)

package okhttp3.internal

import okhttp3.Cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:OptIn(OkHttpInternalApi::class)

package okhttp3.internal.connection

import java.io.IOException
Expand Down Expand Up @@ -59,6 +57,7 @@ import okhttp3.internal.toHostHeader
* Each step may fail. If a retry is possible, a new instance is created with the next plan, which
* will be configured differently.
*/
@OkHttpInternalApi
class ConnectPlan internal constructor(
private val taskRunner: TaskRunner,
private val connectionPool: RealConnectionPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ package okhttp3.internal.connection

import java.io.IOException
import java.net.ProtocolException
import okhttp3.EventListener
import okhttp3.Headers
import okhttp3.Request
import okhttp3.Response
import okhttp3.ResponseBody
import okhttp3.internal.OkHttpInternalApi
import okhttp3.internal.http.ExchangeCodec
import okhttp3.internal.http.RealResponseBody
import okio.Buffer
Expand All @@ -36,6 +36,7 @@ import okio.buffer
* Transmits a single HTTP request and a response pair. This layers connection management and events
* on [ExchangeCodec], which handles the actual I/O.
*/
@OkHttpInternalApi
class Exchange(
internal val call: RealCall,
internal val finder: ExchangeFinder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
package okhttp3.internal.connection

import okhttp3.internal.OkHttpInternalApi

@OkHttpInternalApi
interface ExchangeFinder {
val routePlanner: RoutePlanner

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import java.io.IOException
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.LinkedBlockingDeque
import java.util.concurrent.TimeUnit
import okhttp3.internal.OkHttpInternalApi
import okhttp3.internal.concurrent.Task
import okhttp3.internal.concurrent.TaskRunner
import okhttp3.internal.connection.RoutePlanner.ConnectResult
Expand All @@ -29,6 +30,7 @@ import okhttp3.internal.okHttpName
* Speculatively connects to each IP address of a target address, returning as soon as one of them
* connects successfully. This kicks off new attempts every 250 ms until a connect succeeds.
*/
@OkHttpInternalApi
internal class FastFallbackExchangeFinder(
override val routePlanner: RoutePlanner,
private val taskRunner: TaskRunner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import okhttp3.internal.OkHttpInternalApi
import okhttp3.internal.assertLockNotHeld
import okhttp3.internal.cache.CacheInterceptor
import okhttp3.internal.closeQuietly
Expand All @@ -61,6 +62,7 @@ import okio.Timeout
* the other streams sharing its connection. But if the TLS handshake is still in progress then
* canceling may break the entire connection.
*/
@OkHttpInternalApi
class RealCall(
val client: OkHttpClient,
/** The application's original request unadulterated by redirects or auth headers. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import okhttp3.HttpUrl
import okhttp3.OkHttpClient
import okhttp3.Protocol
import okhttp3.Route
import okhttp3.internal.OkHttpInternalApi
import okhttp3.internal.closeQuietly
import okhttp3.internal.concurrent.Lockable
import okhttp3.internal.concurrent.TaskRunner
Expand Down Expand Up @@ -59,6 +60,7 @@ import okio.Buffer
* Connections are shared in a connection pool. Accesses to the connection's state must be guarded
* by holding a lock on the connection.
*/
@OkHttpInternalApi
class RealConnection internal constructor(
val taskRunner: TaskRunner,
val connectionPool: RealConnectionPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit
import okhttp3.Address
import okhttp3.ConnectionPool
import okhttp3.Route
import okhttp3.internal.OkHttpInternalApi
import okhttp3.internal.closeQuietly
import okhttp3.internal.concurrent.Task
import okhttp3.internal.concurrent.TaskQueue
Expand All @@ -32,6 +33,7 @@ import okhttp3.internal.connection.RealCall.CallReference
import okhttp3.internal.okHttpName
import okhttp3.internal.platform.Platform

@OkHttpInternalApi
class RealConnectionPool internal constructor(
taskRunner: TaskRunner,
/** The maximum number of idle connections across all addresses. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import okhttp3.Protocol
import okhttp3.Request
import okhttp3.Response
import okhttp3.Route
import okhttp3.internal.OkHttpInternalApi
import okhttp3.internal.USER_AGENT
import okhttp3.internal.canReuseConnectionFor
import okhttp3.internal.closeQuietly
Expand All @@ -35,6 +36,7 @@ import okhttp3.internal.connection.RoutePlanner.Plan
import okhttp3.internal.platform.Platform
import okhttp3.internal.toHostHeader

@OkHttpInternalApi
class RealRoutePlanner internal constructor(
private val taskRunner: TaskRunner,
private val connectionPool: RealConnectionPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/
package okhttp3.internal.connection

import okhttp3.internal.OkHttpInternalApi

/** Reuse a connection from the pool. */
@OkHttpInternalApi
internal class ReusePlan(
val connection: RealConnection,
) : RoutePlanner.Plan {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package okhttp3.internal.connection
import java.io.IOException
import okhttp3.Address
import okhttp3.HttpUrl
import okhttp3.internal.OkHttpInternalApi

/**
* Policy on choosing which connection to use for an exchange and any retries that follow. This uses
Expand Down Expand Up @@ -46,6 +47,7 @@ import okhttp3.HttpUrl
* Implementations of this interface are not thread-safe. Each instance is thread-confined to the
* thread executing the call.
*/
@OkHttpInternalApi
interface RoutePlanner {
val address: Address

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import okhttp3.Address
import okhttp3.Dns
import okhttp3.HttpUrl
import okhttp3.Route
import okhttp3.internal.OkHttpInternalApi
import okhttp3.internal.canParseAsIpAddress
import okhttp3.internal.dns.LookupDnsCall
import okhttp3.internal.dns.execute
Expand All @@ -35,6 +36,7 @@ import okhttp3.internal.toImmutableList
* Selects routes to connect to an origin server. Each connection requires a choice of proxy server,
* IP address, and TLS mode. Connections may also be recycled.
*/
@OkHttpInternalApi
class RouteSelector internal constructor(
private val address: Address,
private val routeDatabase: RouteDatabase,
Expand Down Expand Up @@ -249,7 +251,11 @@ class RouteSelector internal constructor(
address = address,
proxy = proxy,
socketAddress = InetSocketAddress(record.address, socketPort),
echConfigList = serviceMetadata?.echConfigList,
echConfigList =
when (proxy.type()) {
Proxy.Type.DIRECT -> serviceMetadata?.echConfigList
else -> null
},

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This was a pretty nasty one. We sent the proxy’s ECH config list to the origin server

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good catch.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This would have manifested as a connectivity problem for clients that use an HTTP proxy, if the HTTP proxy itself has an ECH record. Possibly not likely in practice? Unsure.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Also, I love tests. That’s how we build complex things safely!

)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
package okhttp3.internal.connection

import java.io.IOException
import okhttp3.internal.OkHttpInternalApi

/** Attempt routes one at a time until one connects. */
@OkHttpInternalApi
internal class SequentialExchangeFinder(
override val routePlanner: RoutePlanner,
) : ExchangeFinder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ import okhttp3.Headers
import okhttp3.Request
import okhttp3.Response
import okhttp3.Route
import okhttp3.internal.OkHttpInternalApi
import okhttp3.internal.connection.RealCall
import okio.Sink
import okio.Socket
import okio.Source

/** Encodes HTTP requests and decodes HTTP responses. */
@OkHttpInternalApi
interface ExchangeCodec {
/** The connection or CONNECT tunnel that owns this codec. */
val carrier: Carrier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

@file:JvmName("Internal")
@file:Suppress("ktlint:standard:filename")
@file:OptIn(OkHttpInternalApi::class)

package okhttp3.internal

Expand Down
Loading
Loading