Hey guys, I am trying to get the body of requests ...
# ktor
s
Hey guys, I am trying to get the body of requests by using
call.receiveText()
but it is always empty. I am using version 0.9.4. I saw on the following post on stackoverflow that it was a known issue fixed in v0.9.2. Anyone knows if it is still an issue in the latest version ? https://stackoverflow.com/questions/49895169/ktor-unable-to-receive-post-body-on-server
б
Are you sure your request is non-empty plain text ?
s
Yes I am sure, I will check if it is not an issue with Insomnia (my REST client)
I am sorry for the noise for some reason Insomnia wasn’t sending the body. It worked with curl.
Actually it wasn’t Insomnia. I was able to reproduce. The body is empty when I add the HTTPS redirection
Copy code
install(HttpsRedirect) {
        sslPort = 8443
    }
б
And the response code is 302, right ?
s
Thank you for you answer. For example for the following route
Copy code
get("/") {
            call.respondText(call.receiveText(), contentType = ContentType.Text.Plain)
        }
I get a response with a status code of 200 from the server but the body is empty and the logging on the server shows an empty body even though I sent a body in the request. If I change the request from get to post I get a redirection with a GET instead of POST. The logs of the two cases are below.
the logs of the two cases
Screen Shot 2018-09-08 at 20.50.24.png
I guess it is the expected behaviour without a 307 redirection ?