@@ -79,18 +79,28 @@ internal class OkHttpNetwork(
79
79
apiBaseUrl : HttpUrl ,
80
80
timeoutSeconds : Long = 2L * 60 ,
81
81
) : ICaptureNetwork {
82
- private val client: OkHttpClient = OkHttpClient ().newBuilder()
83
- .protocols(
84
- if (apiBaseUrl.scheme == " https" ) {
85
- listOf (Protocol .HTTP_2 , Protocol .HTTP_1_1 )
86
- } else {
87
- listOf (Protocol .H2_PRIOR_KNOWLEDGE )
88
- },
89
- )
90
- .writeTimeout(timeoutSeconds, TimeUnit .SECONDS )
91
- .readTimeout(timeoutSeconds, TimeUnit .SECONDS )
92
- .retryOnConnectionFailure(false ) // Retrying messes up the write pipe state management, so disable.
93
- .build()
82
+ private val client: OkHttpClient =
83
+ run {
84
+ val builder = OkHttpClient ().newBuilder()
85
+ // Certain other libraries will manipulate the bytecode to have the OkHttpClientBuilder
86
+ // constructor automatically add interceptors which tend to not work well with our bespoke
87
+ // client implementation. Remove these extra interceptors here to ensure that we are using
88
+ // a standard client.
89
+ builder.interceptors().clear()
90
+ builder.networkInterceptors().clear()
91
+ builder
92
+ .protocols(
93
+ if (apiBaseUrl.scheme == " https" ) {
94
+ listOf (Protocol .HTTP_2 , Protocol .HTTP_1_1 )
95
+ } else {
96
+ listOf (Protocol .H2_PRIOR_KNOWLEDGE )
97
+ },
98
+ )
99
+ .writeTimeout(timeoutSeconds, TimeUnit .SECONDS )
100
+ .readTimeout(timeoutSeconds, TimeUnit .SECONDS )
101
+ .retryOnConnectionFailure(false ) // Retrying messes up the write pipe state management, so disable.
102
+ .build()
103
+ }
94
104
95
105
private val executor: ExecutorService = Executors .newSingleThreadExecutor {
96
106
Thread (it, " io.bitdrift.capture.network.okhttp" )
0 commit comments