readLine() loop not exiting until remote client closes connection

风格不统一 提交于 2019-11-29 18:09:48

The problem i'm having is that the server code seems to freeze as while((line = reader.readLine()) != null) until the remote client closes the connection.

That's not a problem: it is the correct, specified behaviour.

The problem is that you aren't implementing HTTP correctly. You need a good knowledge of RFC 2616 and its successors, particularly the parts about content length add transfer encoding. This code doesn't exhibit any knowledge of it whatsoever.

And why for example are you sending HTTP 200 before processing the request? How do you know the request processor won't want to return a different code?

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