Skip to content

Commit f5546f8

Browse files
cortinicometa-codesync[bot]
authored andcommitted
Make DevSupportHttpClient internal (#55883)
Summary: Pull Request resolved: #55883 All 7 callers of DevSupportHttpClient are within ReactAndroid, so there is no need to expose it as a public API. Make the class and all its members internal. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D95059038
1 parent 3582a8b commit f5546f8

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,16 +2049,6 @@ public final class com/facebook/react/devsupport/StackTraceHelper$StackFrameImpl
20492049
public fun toJSON ()Lorg/json/JSONObject;
20502050
}
20512051

2052-
public final class com/facebook/react/devsupport/inspector/DevSupportHttpClient {
2053-
public static final field INSTANCE Lcom/facebook/react/devsupport/inspector/DevSupportHttpClient;
2054-
public static final fun addRequestHeader (Ljava/lang/String;Ljava/lang/String;)V
2055-
public final fun getHttpClient ()Lokhttp3/OkHttpClient;
2056-
public final fun getWebsocketClient ()Lokhttp3/OkHttpClient;
2057-
public static final fun httpScheme (Ljava/lang/String;)Ljava/lang/String;
2058-
public static final fun removeRequestHeader (Ljava/lang/String;)V
2059-
public static final fun wsScheme (Ljava/lang/String;)Ljava/lang/String;
2060-
}
2061-
20622052
public abstract interface class com/facebook/react/devsupport/interfaces/BundleLoadCallback {
20632053
public fun onError (Ljava/lang/Exception;)V
20642054
public abstract fun onSuccess ()V

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import okhttp3.OkHttpClient
1919
* dispatcher across all dev support HTTP and WebSocket usage. Supports injecting custom request
2020
* headers that are applied to every outgoing request via an OkHttp interceptor.
2121
*/
22-
public object DevSupportHttpClient {
22+
internal object DevSupportHttpClient {
2323
private val customHeaders = ConcurrentHashMap<String, String>()
2424

2525
private val headerInterceptor = Interceptor { chain ->
@@ -31,7 +31,7 @@ public object DevSupportHttpClient {
3131
}
3232

3333
/** Client for HTTP requests: connect=5s, write=disabled, read=disabled. */
34-
public val httpClient: OkHttpClient =
34+
internal val httpClient: OkHttpClient =
3535
OkHttpClient.Builder()
3636
.addInterceptor(headerInterceptor)
3737
.connectTimeout(5, TimeUnit.SECONDS)
@@ -40,35 +40,32 @@ public object DevSupportHttpClient {
4040
.build()
4141

4242
/** Client for WebSocket connections: connect=10s, write=10s, read=disabled. */
43-
public val websocketClient: OkHttpClient =
43+
internal val websocketClient: OkHttpClient =
4444
httpClient
4545
.newBuilder()
4646
.connectTimeout(10, TimeUnit.SECONDS)
4747
.writeTimeout(10, TimeUnit.SECONDS)
4848
.build()
4949

5050
/** Add a custom header to be included in all requests made through both clients. */
51-
@JvmStatic
52-
public fun addRequestHeader(name: String, value: String) {
51+
internal fun addRequestHeader(name: String, value: String) {
5352
customHeaders[name] = value
5453
}
5554

5655
/** Remove a previously added custom header. */
57-
@JvmStatic
58-
public fun removeRequestHeader(name: String) {
56+
internal fun removeRequestHeader(name: String) {
5957
customHeaders.remove(name)
6058
}
6159

6260
/**
6361
* Returns the appropriate HTTP scheme ("http" or "https") for the given host. Uses "https" when
6462
* the host specifies port 443 explicitly (e.g. "example.com:443").
6563
*/
66-
@JvmStatic
67-
public fun httpScheme(host: String): String = if (host.endsWith(":443")) "https" else "http"
64+
internal fun httpScheme(host: String): String = if (host.endsWith(":443")) "https" else "http"
6865

6966
/**
7067
* Returns the appropriate WebSocket scheme ("ws" or "wss") for the given host. Uses "wss" when
7168
* the host specifies port 443 explicitly (e.g. "example.com:443").
7269
*/
73-
@JvmStatic public fun wsScheme(host: String): String = if (host.endsWith(":443")) "wss" else "ws"
70+
internal fun wsScheme(host: String): String = if (host.endsWith(":443")) "wss" else "ws"
7471
}

0 commit comments

Comments
 (0)