Does servlet engine read the whole request before calling a servlet?

核能气质少年 提交于 2019-12-11 02:28:19

问题


Servlet engine (e.g. Tomcat or Jetty) receives an HTTP request and calls a servlet with an HttpServletRequest object, which contains an InputStream of the request body.

Now I wonder if the engine has already read the whole request from the network and the InputStream is just a buffer in memory or it has read the request partially and when the servlet calls the InputStream.read it actually reads the socket.


回答1:


Usually that's not the case, because the request body can be really huge. A servlet container MAY do that if the content length is known and is small enough.




回答2:


It has to, at least in the case of POST, so it can form the requestParameterMap from the name-value pairs in the body of the request.



来源:https://stackoverflow.com/questions/18561092/does-servlet-engine-read-the-whole-request-before-calling-a-servlet

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