Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
PratikBodawala committed Aug 26, 2024
1 parent e9dad48 commit 0675e7a
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,18 @@ class NativeWebAPI {
connection.setRequestProperty(it.key, it.value)
}

if (options.body != null) {
val requestBody = options.body
if (requestBody != null) {
connection.doOutput = true
connection.setChunkedStreamingMode(0)
val contentEncoding = options.headers["Transfer-Encoding"]
if (contentEncoding == "chunked") {
connection.setChunkedStreamingMode(0)
} else {
connection.setFixedLengthStreamingMode(requestBody.size)
}

val output = BufferedOutputStream(connection.outputStream)
output.write(options.body)
output.write(requestBody)
output.flush()
}
}
Expand Down

0 comments on commit 0675e7a

Please sign in to comment.