mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Gate requestBody processing behind BuildConfig.DEBUG (#54920)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/54920 Gates `requestBody` handling for `reportRequestStart` on Android with `BuildConfig.DEBUG`. This is an appropriate optimisation as we do not use body previews outside of CDP debugging, aligning with the same conditional behaviour on iOS. I'd like to also pick this change for 0.83.1, with D89373824, for additional safety. **Other notes** Gating by `BuildConfig` isn't done elsewhere in this file, as other potentially expensive behaviour is gated lower down by both `REACT_NATIVE_DEBUGGER_ENABLED` and the `Network.enable` CDP message. This was the only remaining gap with the iOS implementation. Changelog: [Internal] Reviewed By: vzaidman Differential Revision: D89377163 fbshipit-source-id: 10a27f6b02f65755d4293f5cf33697d542bc9465
This commit is contained in:
1 parent
9692e6488e
commit
33005a48fe
1 file changed
+11
-2
+11
-2
@@ -15,6 +15,7 @@ import com.facebook.react.bridge.Arguments
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.bridge.WritableMap
|
||||
import com.facebook.react.bridge.buildReadableArray
|
||||
import com.facebook.react.common.build.ReactBuildConfig
|
||||
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
|
||||
import java.net.SocketTimeoutException
|
||||
import okhttp3.Headers
|
||||
@@ -30,13 +31,21 @@ internal object NetworkEventUtil {
|
||||
fun onCreateRequest(devToolsRequestId: String, request: Request) {
|
||||
if (ReactNativeFeatureFlags.enableNetworkEventReporting()) {
|
||||
val headersMap = okHttpHeadersToMap(request.headers())
|
||||
var requestBody = ""
|
||||
|
||||
if (ReactBuildConfig.DEBUG) {
|
||||
// Debug build: Process request body for preview (CDP only)
|
||||
requestBody =
|
||||
(request.body() as? ProgressRequestBody)?.getBodyPreview()
|
||||
?: request.body()?.toString().orEmpty()
|
||||
}
|
||||
|
||||
InspectorNetworkReporter.reportRequestStart(
|
||||
devToolsRequestId,
|
||||
request.url().toString(),
|
||||
request.method(),
|
||||
headersMap,
|
||||
(request.body() as? ProgressRequestBody)?.getBodyPreview()
|
||||
?: request.body()?.toString().orEmpty(),
|
||||
requestBody,
|
||||
request.body()?.contentLength() ?: 0,
|
||||
)
|
||||
InspectorNetworkReporter.reportConnectionTiming(devToolsRequestId, headersMap)
|
||||
|
||||
Reference in new issue
Block a user