fix: default body to empty string if not present for FlareSolverr POST requests (#1915)
* fix: convert `RequestBody` to `FormBody` in FlareSolverr `POST` requests * linting * ref: don't convert json to form * remove unused import
This commit is contained in:
+12
-4
@@ -211,10 +211,18 @@ object CFClearance {
|
||||
returnOnlyCookies = onlyCookies,
|
||||
maxTimeout = timeout.inWholeMilliseconds.toInt(),
|
||||
postData =
|
||||
if (originalRequest.method == "POST" && originalRequest.body is FormBody) {
|
||||
Buffer()
|
||||
.also { (originalRequest.body as FormBody).writeTo(it) }
|
||||
.readUtf8()
|
||||
if (originalRequest.method == "POST") {
|
||||
when (val body = originalRequest.body) {
|
||||
is FormBody -> {
|
||||
Buffer()
|
||||
.also { body.writeTo(it) }
|
||||
.readUtf8()
|
||||
}
|
||||
|
||||
else -> {
|
||||
""
|
||||
}
|
||||
}
|
||||
} else {
|
||||
null
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user