Skip to content
Closed
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 @@ -23,10 +23,6 @@ internal class ProgressRequestBody(
) : RequestBody() {
private var contentLength = 0L

companion object {
private const val MAX_BODY_PREVIEW_SIZE = 1024 * 1024 // 1MB
}

override fun contentType(): MediaType? {
return requestBody.contentType()
}
Expand Down Expand Up @@ -84,18 +80,7 @@ internal class ProgressRequestBody(
}

fun getBodyPreview(): String {
return try {
val buffer = okio.Buffer()
requestBody.writeTo(buffer)
val size = buffer.size()
if (size <= MAX_BODY_PREVIEW_SIZE) {
buffer.readUtf8()
} else {
buffer.readUtf8(MAX_BODY_PREVIEW_SIZE.toLong()) +
"\n... [truncated, showing $MAX_BODY_PREVIEW_SIZE of $size bytes]"
}
} catch (e: Exception) {
""
}
// TODO: Safely implement request body previews
return "[Preview unavailable]"
}
}
Loading