问题
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