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:
David Brochero
2026-02-20 22:09:34 -03:00
committed by GitHub
parent 2249d237dd
commit f977d181a8

View File

@@ -211,10 +211,18 @@ object CFClearance {
returnOnlyCookies = onlyCookies, returnOnlyCookies = onlyCookies,
maxTimeout = timeout.inWholeMilliseconds.toInt(), maxTimeout = timeout.inWholeMilliseconds.toInt(),
postData = postData =
if (originalRequest.method == "POST" && originalRequest.body is FormBody) { if (originalRequest.method == "POST") {
Buffer() when (val body = originalRequest.body) {
.also { (originalRequest.body as FormBody).writeTo(it) } is FormBody -> {
.readUtf8() Buffer()
.also { body.writeTo(it) }
.readUtf8()
}
else -> {
""
}
}
} else { } else {
null null
}, },