Engine组件 - 969251639/study GitHub Wiki

tomcat的engine主要包括两大块一个时host,一个是context,顾名思义,host代表一个虚拟主机,而context代表主机下面的多个路由
它的主要职责是将Connector接收到的请求通过管道的方式流向它的子组件

    @Override
    public final void invoke(Request request, Response response)
        throws IOException, ServletException {

        // Select the Host to be used for this Request
        //找到对应的虚拟主机
        Host host = request.getHost();
        if (host == null) {
            response.sendError
                (HttpServletResponse.SC_BAD_REQUEST,
                 sm.getString("standardEngine.noHost",
                              request.getServerName()));
            return;
        }
        if (request.isAsyncSupported()) {
            request.setAsyncSupported(host.getPipeline().isAsyncSupported());
        }

        // Ask this Host to process this request
        host.getPipeline().getFirst().invoke(request, response);

    }

接下来的处理就交由host来处理了