问题
The below snippet is taken from the quick start on the Ktor website.
val server = embeddedServer(Netty, port = 8080) {
routing {
get("/") {
call.respondText("Hello World!", ContentType.Text.Plain)
}
get("/demo") {
call.respondText("HELLO WORLD!")
}
}
server.start(wait = true)
My console output looks like this
[07:32:13.144 INFO ] application | No ktor.deployment.watch patterns specified, automatic reload is not active
[07:32:13.308 INFO ] application | Responding at http://0.0.0.0:8080
I looked at this question and tried adding host = localhost
but this did not fix my issue. I am accessing the link http://127.0.0.1:8080/demo
like the quick start page directs but am getting ERR_EMPTY_RESPONSE
.
I have also tried to send a curl -i http://127.0.0.1/demo
request from the same machine but receive (52) Empty reply from server
.
来源:https://stackoverflow.com/questions/55412555/ktor-netty-server-is-returning-empty-response