aleksey.tomin
05/18/2020, 5:54 AMcurl_easy_setopt(curl, CURLOPT_PORT, 443L)
curl_easy_setopt(curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS)
and method POST
fun post(postData: String) {
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headersCRef)
val cstr = postData.cstr
curl_easy_setopt(curl, CURLOPT_POST, 1)
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, cstr)
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, cstr.size)
val res = curl_easy_perform(curl)
curl_slist_free_all(headersCRef)
if (res != CURLE_OK) {
throw RuntimeException("curl_easy_perform() failed: ${curl_easy_strerror(res)?.toKString()}")
}
}
But the server accepts wrong data - without some chars (at the start or at the end).
What I do wrong? How it can be fixed?
FIXED:
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, cstr)
->
_curl_easy_setopt_(curl, _CURLOPT_POSTFIELDS_, cstr.getPointer(MemScope()))
napperley
05/18/2020, 10:49 PMaleksey.tomin
05/19/2020, 3:05 AMgetPointer(MemScope())
it didn’t work 🙂v79
11/27/2020, 4:57 PMdata.cstr.getPointer(MemScope())
actually does, but it does work. Thank you, @aleksey.tomin, I've been trying for hours to get a curl POST to work. And I agree, `CURLOPT_COPYPOSTFIELDS`doesn't work; in fact, it seems to hang the application.aleksey.tomin
11/27/2020, 4:59 PMv79
11/27/2020, 5:03 PM