File tree Expand file tree Collapse file tree
packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/network Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
1919import java.io.IOException
2020import java.net.SocketTimeoutException
2121import okhttp3.Headers
22+ import okhttp3.MultipartBody
2223import okhttp3.RequestBody
2324import okio.Buffer
2425
@@ -263,6 +264,13 @@ internal object NetworkEventUtil {
263264 return " [Preview unavailable]"
264265 }
265266
267+ // MultipartBody does not propagate isOneShot() from its parts, so check each
268+ // part explicitly. Reading a one-shot part here would drain the underlying
269+ // stream and cause the real request to fail.
270+ if (body is MultipartBody && body.parts().any { it.body().isOneShot() }) {
271+ return " [Preview unavailable]"
272+ }
273+
266274 return try {
267275 val buffer = Buffer ()
268276 body.writeTo(buffer)
Original file line number Diff line number Diff line change @@ -146,6 +146,8 @@ internal object RequestBodyUtil {
146146 }
147147 }
148148
149+ override fun isOneShot (): Boolean = true
150+
149151 @Throws(IOException ::class )
150152 override fun writeTo (sink : BufferedSink ) {
151153 var source: Source ? = null
You can’t perform that action at this time.
0 commit comments