Ktor Netty Server is returning empty response

余生颓废 提交于 2019-12-13 03:49:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!