tomact如何处理一个http请求?
生活随笔
收集整理的這篇文章主要介紹了
tomact如何处理一个http请求?
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
tomcat 從http 端口接收到一個(gè)請(qǐng)求后:
1.
2.
3.
Tomcat receives a request on an HTTP portd1) The request is received by a separate thread which is waiting in the PoolTcpEndPoint class. It is waiting for a request in a regular ServerSocket.accept() method.When a request is received, this thread wakes up.d2) The PoolTcpEndPoint assigns the a TcpConnection to handle the request. It also supplies a JMX object name to the catalina container (not used I believe)d3) The processor to handle the request in this case is Coyote Http11Processor, and the process method is invoked.This same processor is also continuing to check the input stream of the socketuntil the keep alive point is reached or the connection is disconnected.d4) The HTTP request is parsed using an internal buffer class (Coyote Http11 Internal Buffer)The buffer class parses the request line, the headers, etc and store the result in a Coyote request (not an HTTP request) This request contains all the HTTP info, suchas servername, port, scheme, etc.d5) The processor contains a reference to an Adapter, in this case it is the Coyote Tomcat 5 Adapter. Once the request has been parsed, the Http11 processorinvokes service() on the adapter. In the service method, the Request contains a CoyoteRequest and CoyoteRespons (null for the first time)The CoyoteRequest(Response) implements HttpRequest(Response) and HttpServletRequest(Response)The adapter parses and associates everything with the request, cookies, the context through a Mapper, etcd6) When the parsing is finished, the CoyoteAdapter invokes its container (StandardEngine)and invokes the invoke(request,response) method.This initiates the HTTP request into the Catalina container starting at the engine leveld7) The StandardEngine.invoke() simply invokes the container pipeline.invoke()d8) By default the engine only has one valve the StandardEngineValve, this valve simplyinvokes the invoke() method on the Host pipeline (StandardHost.getPipeLine())d9) the StandardHost has two valves by default, the StandardHostValve and the ErrorReportValved10) The standard host valve associates the correct class loader with the current threadIt also retrieves the Manager and the session associated with the request (if there is one)If there is a session access() is called to keep the session alived11) After that the StandardHostValve invokes the pipeline on the context associatedwith the request.d12) The first valve that gets invoked by the Context pipeline is the FormAuthenticatorvalve. Then the StandardContextValve gets invoke.The StandardContextValve invokes any context listeners associated with the context.Next it invokes the pipeline on the Wrapper component (StandardWrapperValve)d13) During the invocation of the StandardWrapperValve, the JSP wrapper (Jasper) gets invokedThis results in the actual compilation of the JSP.And then invokes the actual servlet.e) Invocation of the servlet class
轉(zhuǎn)載于:https://www.cnblogs.com/davidwang456/archive/2013/03/23/2976635.html
總結(jié)
以上是生活随笔為你收集整理的tomact如何处理一个http请求?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tomcat源码分析(一)初始化---D
- 下一篇: group by 和 having(转载