Skip to content

Commit 7bf86e7

Browse files
cortinicofacebook-github-bot
authored andcommitted
Remove custom header support from DevSupportHttpClient (facebook#55884)
Summary: The addRequestHeader/removeRequestHeader methods don't need to live inside devsupport. Instead we can use the `setOkHttpClientFactory` to provide this same logic. Changelog: [Internal] Reviewed By: javache, cipolleschi Differential Revision: D95059080
1 parent 28d944a commit 7bf86e7

1 file changed

Lines changed: 1 addition & 25 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/DevSupportHttpClient.kt

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,17 @@
99

1010
package com.facebook.react.devsupport.inspector
1111

12-
import java.util.concurrent.ConcurrentHashMap
1312
import java.util.concurrent.TimeUnit
14-
import okhttp3.Interceptor
1513
import okhttp3.OkHttpClient
1614

1715
/**
1816
* Shared [OkHttpClient] instances for devsupport networking. Uses a single connection pool and
19-
* dispatcher across all dev support HTTP and WebSocket usage. Supports injecting custom request
20-
* headers that are applied to every outgoing request via an OkHttp interceptor.
17+
* dispatcher across all dev support HTTP and WebSocket usage.
2118
*/
2219
internal object DevSupportHttpClient {
23-
private val customHeaders = ConcurrentHashMap<String, String>()
24-
25-
private val headerInterceptor = Interceptor { chain ->
26-
val builder = chain.request().newBuilder()
27-
for ((name, value) in customHeaders) {
28-
builder.header(name, value)
29-
}
30-
chain.proceed(builder.build())
31-
}
32-
3320
/** Client for HTTP requests: connect=5s, write=disabled, read=disabled. */
3421
internal val httpClient: OkHttpClient =
3522
OkHttpClient.Builder()
36-
.addInterceptor(headerInterceptor)
3723
.connectTimeout(5, TimeUnit.SECONDS)
3824
.writeTimeout(0, TimeUnit.MILLISECONDS)
3925
.readTimeout(0, TimeUnit.MINUTES)
@@ -47,16 +33,6 @@ internal object DevSupportHttpClient {
4733
.writeTimeout(10, TimeUnit.SECONDS)
4834
.build()
4935

50-
/** Add a custom header to be included in all requests made through both clients. */
51-
internal fun addRequestHeader(name: String, value: String) {
52-
customHeaders[name] = value
53-
}
54-
55-
/** Remove a previously added custom header. */
56-
internal fun removeRequestHeader(name: String) {
57-
customHeaders.remove(name)
58-
}
59-
6036
/**
6137
* Returns the appropriate HTTP scheme ("http" or "https") for the given host. Uses "https" when
6238
* the host specifies port 443 explicitly (e.g. "example.com:443").

0 commit comments

Comments
 (0)