Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import java.io.IOException
import java.net.SocketTimeoutException
import okhttp3.Headers
import okhttp3.MultipartBody
import okhttp3.RequestBody
import okio.Buffer

Expand Down Expand Up @@ -263,6 +264,13 @@ internal object NetworkEventUtil {
return "[Preview unavailable]"
}

// MultipartBody does not propagate isOneShot() from its parts, so check each
// part explicitly. Reading a one-shot part here would drain the underlying
// stream and cause the real request to fail.
if (body is MultipartBody && body.parts().any { it.body().isOneShot() }) {
return "[Preview unavailable]"
}

return try {
val buffer = Buffer()
body.writeTo(buffer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ internal object RequestBodyUtil {
}
}

override fun isOneShot(): Boolean = true

@Throws(IOException::class)
override fun writeTo(sink: BufferedSink) {
var source: Source? = null
Expand Down
Loading