This implementation don't actually use request dispatcher for the
forwarding. It runs forwarding logic, and renders its <b>default</b>
view.
548049
@Override
	public <T> T forwardTo(final Class<T> type) {
		return proxifier.proxify(type, new MethodInvocation<T>() {

			@Override
			public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) {
				try {
					logger.debug("Executing {}", method);
					ControllerMethod old = methodInfo.getControllerMethod();
					methodInfo.setControllerMethod(DefaultControllerMethod.instanceFor(type, method));
					Object methodResult = method.invoke(container.instanceFor(type), args);
					methodInfo.setControllerMethod(old);

					Type returnType = method.getGenericReturnType();
					if (!(returnType == void.class)) {
						request.setAttribute(extractor.nameFor(returnType), methodResult);
					}
					
					if (response.isCommitted()) {
						logger.debug("Response already commited, not forwarding.");
						return null;
					}
					String path = resolver.pathFor(DefaultControllerMethod.instanceFor(type, method));
					logger.debug("Forwarding to {}", path);
					request.getRequestDispatcher(path).forward(request, response);
					return null;
				} catch (InvocationTargetException e) {
					propagateIfPossible(e.getCause());
					throw new ProxyInvocationException(e);
				} catch (Exception e) {
					throw new ProxyInvocationException(e);
				}
			}
		});
	}
647073
@Override
  protected <T1, R extends Completes<?>> R dispatchQuery(BiFunction<P, T1, R> query, T1 routable1) {
    throw new UnsupportedOperationException("query protocols are not supported by this router by default");
  }
1246947
@Override
    public RequestDispatcher getRequestDispatcher(String arg0) {
        try {
            collaborator.preInvoke(componentMetaData);
            return request.getRequestDispatcher(arg0);
        } finally {
            collaborator.postInvoke();
        }
    }
208862
private static synchronized void proxyInit() {
        if (PROXY_HOST != null && customRouterPlanner == null) {
            HttpHost proxy = new HttpHost(PROXY_HOST, PROXY_PORT);
            customRouterPlanner = new DefaultProxyRoutePlanner(proxy);
        }
    }
9558
protected boolean processUnhandledAction( HttpServletRequest request, HttpServletResponse response, String uri )
        throws IOException, ServletException
    {
        //
        // First check to see if we're already in a forwarded fallback request.  If so, just bail.
        //
        PageFlowRequestWrapper rw = PageFlowRequestWrapper.get( request );
        if ( rw.getOriginalServletPath() != null ) return false;       
        
        SharedFlowController sharedFlowToTry = null;
        String uriBaseName = ServletUtils.getBaseName( uri );
        int firstDot = uriBaseName.indexOf( '.' );
        int lastDot = uriBaseName.lastIndexOf( '.' );
        
        if ( firstDot != -1 && firstDot != lastDot )
        {
            String sharedFlowName = uriBaseName.substring( 0, firstDot );
            
            try
            {
                RequestContext rc = new RequestContext( request, response );
                Map defaultSharedFlows = FlowControllerFactory.get( getServletContext() ).getDefaultSharedFlows( rc );
                
                if ( defaultSharedFlows != null )
                {
                    sharedFlowToTry = ( SharedFlowController ) defaultSharedFlows.get( sharedFlowName );
                    uriBaseName = uriBaseName.substring( firstDot + 1 );
                }
            }
            catch ( ClassNotFoundException e )
            {
                ServletUtils.throwServletException(e);
            }
            catch ( InstantiationException e )
            {
                ServletUtils.throwServletException(e);
            }
            catch ( IllegalAccessException e )
            {
                ServletUtils.throwServletException(e);
            }
        }
        else
        {
            sharedFlowToTry = FlowControllerFactory.getGlobalApp( request, response, getServletContext() );
        }
        
        //
        // If we couldn't find an appropriate module, try raising the action on the (deprecated) Global.app.
        //
        
        if ( sharedFlowToTry != null )
        {
            InternalStringBuilder sfActionURI = new InternalStringBuilder( sharedFlowToTry.getModulePath() );
            sfActionURI.append( '/' );
            sfActionURI.append( uriBaseName );
            rw.setOriginalServletPath( uri );
            ForwardRedirectHandler frh = _handlers.getForwardRedirectHandler();
            FlowControllerHandlerContext context = new FlowControllerHandlerContext( request, response, null );
            frh.forward( context, sfActionURI.toString() );
            return true;
        }
        
        return false;
    }
875013
def mk_request_non(self, method, path):
        
        request = Request()
        request.destination = self.server
        request.code = method.number
        request.uri_path = path
        request.type = defines.Types["NON"]
        return request
412545
private void forwardRequest(Request request, boolean subsequent) {

		if(logger.isDebugEnabled()) {
			logger.debug("creating cloned Request for proxybranch " + request);
		}
		final SipServletRequestImpl clonedRequest = (SipServletRequestImpl) proxy.getSipFactoryImpl().getMobicentsSipServletMessageFactory().createSipServletRequest(
				request,
				null,
				null, null, false);
		
		if(logger.isDebugEnabled()) {
			logger.debug("forwardRequest - clonedRequest=" + clonedRequest);
		}
		
		if(subsequent) {
			if(logger.isDebugEnabled()) {
				logger.debug("forwardRequest - setRoutingState to SUBSEQUENT");
			}
			clonedRequest.setRoutingState(RoutingState.SUBSEQUENT);
		}
		
		this.outgoingRequest = clonedRequest;
		
		// Initialize the sip session for the new request if initial
		final MobicentsSipSession originalSipSession = originalRequest.getSipSession();
		if(logger.isDebugEnabled()) {
			logger.debug("forwardRequest - originalSipSession=" + originalSipSession);
			logger.debug("forwardRequest - originalRequest.getCurrentApplicationName()=" + originalRequest.getCurrentApplicationName());
		}
		
		clonedRequest.setCurrentApplicationName(originalRequest.getCurrentApplicationName());
		if(clonedRequest.getCurrentApplicationName() == null && subsequent) {
			if(logger.isDebugEnabled()) {
				logger.debug("forwardRequest - originalSipSession.getSipApplicationSession().getApplicationName()=" + originalSipSession.getSipApplicationSession().getApplicationName());
			}
			clonedRequest.setCurrentApplicationName(originalSipSession.getSipApplicationSession().getApplicationName());
		}
		clonedRequest.setSipSession(originalSipSession);
		final MobicentsSipSession newSession = (MobicentsSipSession) clonedRequest.getSipSession();
		try {
			if(logger.isDebugEnabled()) {
				logger.debug("forwardRequest - calling setHandler - originalSipSession.getHandler()=" + originalSipSession.getHandler());
			}
			newSession.setHandler(originalSipSession.getHandler());
		} catch (ServletException e) {
			logger.error("could not set the session handler while forwarding the request", e);
			throw new RuntimeException("could not set the session handler while forwarding the request", e);
		}
		
		// Use the original dialog in the new session
		// commented out proxy applications shouldn't use any dialogs !!!
//		newSession.setSessionCreatingDialog(originalSipSession.getSessionCreatingDialog());
		
		// And set a reference to the proxy		
		newSession.setProxy(proxy);		
				
		try {
			if(logger.isDebugEnabled()) {
				logger.debug("forwardRequest - calling checkRequest");
			}
			RFC5626Helper.checkRequest(this, request, originalRequest);
		} catch (IncorrectFlowIdentifierException e1) {
			if(logger.isDebugEnabled()) {
				logger.debug("forwardRequest - checkRequest threw an exception", e1);
			}
			logger.warn(e1.getMessage());
			this.cancel();
			try {
				originalRequest.createResponse(403).send();
			} catch (IOException e) {
				logger.error("couldn't send 403 response", e1);
			}
			return;
		}
		//JSR 289 Section 15.1.6
		if(!subsequent) {
			if(logger.isDebugEnabled()) {
				logger.debug("forwardRequest - not subsequent");
			}
			// Subsequent requests can't have a routing directive?
			clonedRequest.setRoutingDirective(SipApplicationRoutingDirective.CONTINUE, originalRequest);
		}
		if(logger.isDebugEnabled()) {
			logger.debug("forwardRequest - setting the proxy branch");
		}
		clonedRequest.getTransactionApplicationData().setProxyBranch(this);			
		try {
			if(logger.isDebugEnabled()) {
				logger.debug("forwardRequest - sending the cloned request=" + clonedRequest);
			}
			clonedRequest.send();			
		} catch (IOException e) {
			throw new IllegalStateException(e);
		}
		proxy.putTransaction(clonedRequest);
	}
894328
public Optional<EndpointRouter> getRouter(EndpointRouter.Protocol protocol) {
      return endpointRouters.stream().filter(r -> r.getProtocol() == protocol).findFirst();
   }
78176
function FrontRouter() {
    var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

    _classCallCheck(this, FrontRouter);

    this.options = {
      pageRoot: opts.pageRoot || process.cwd(),
      overwrite: opts.overwrite || false
    };
    this.routes = [];

    // Figure out what library to load
    switch (_typeof(opts.library)) {
      // String: pull a library out of the built-in ones
      case 'string':
        {
          var lib = Libraries[opts.library];
          if (typeof lib === 'undefined') {
            throw new Error('Front Router: there\'s no built-in plugin for "' + opts.library + '"');
          } else {
            this.options.library = lib;
          }
          break;
        }
      // Function: add as-is
      case 'function':
        {
          this.options.library = opts.library;
          break;
        }
      // Nothing: use the default library adapter
      case 'undefined':
        {
          this.options.library = Libraries.default;
          break;
        }
      // Other weird values? Nope
      default:
        {
          throw new Error('Front Router: library must be a string or function.');
        }
    }
  }
268620
def get_default_renderer(self, view):
        
        renderers = [renderer for renderer in view.renderer_classes
                     if not issubclass(renderer, BrowsableAPIRenderer)]
        non_template_renderers = [renderer for renderer in renderers
                                  if not hasattr(renderer, 'get_template_names')]

        if not renderers:
            return None
        elif non_template_renderers:
            return non_template_renderers[0]()
        return renderers[0]()
502908
protected void initRequest()
  {
    _hostHeader = null;
    _xForwardedHostHeader = null;
    _expect100Continue = false;

    _cookies.clear();

    _contentLengthIn = -1;

    _hasReadStream = false;

    _readEncoding = null;

    //_request = request;
    //_requestFacade = getHttp().createFacade(this);
    
    _startTime = -1;
    _expireTime = -1;
    
    _isUpgrade = false;
    
    _statusCode = 200;
    _statusMessage = "OK";

    _headerKeysOut.clear();
    _headerValuesOut.clear();
    
    _contentTypeOut = null;
    _contentEncodingOut = null;
    _contentLengthOut = -1;

    _footerKeys.clear();
    _footerValues.clear();

    out().start();

    _isHeaderWritten = false;

    _isClosed = false;
    //_serverHeader = http().serverHeader();
    
    _isKeepalive = true;
  }
545266
def dispatch(self, request, *args, **kwargs):
        

        self.return_url = request.GET.get('return_url', None)
        referrer = request.META.get('HTTP_REFERER', None)

        # leave alone POST and ajax requests and if return_url is explicitly left empty
        if (request.method != "GET" or
                request.is_ajax() or
                self.return_url or
                referrer is None or
                self.return_url is None and 'return_url' in request.GET):
            return super().dispatch(request, *args, **kwargs)

        if not self.return_url:
            url = request.get_full_path()
            if url.find("?") < 0:
                url = "?return_url=".join((url, referrer))
            else:
                url = "&return_url=".join((url, referrer))
            return HttpResponseRedirect(url)
610982
protected boolean routingToAction(HttpServletRequest request, HttpServletResponse response, String contextPath, String requestPath,
            String actionName, String paramPath, ActionExecute execByParam) throws IOException, ServletException {
        if (execByParam != null) { // already found
            processAction(request, response, execByParam, paramPath); // #to_action
            return true;
        }
        final OptionalThing<ActionExecute> found = LaActionExecuteUtil.findActionExecute(actionName, request);
        if (found.isPresent()) { // not use lambda because of throws definition
            final ActionExecute execute = found.get();
            if (needsTrailingSlashRedirect(request, requestPath, execute)) { // index() or by request parameter
                redirectWithTrailingSlash(request, response, contextPath, requestPath);
            } else {
                processAction(request, response, execute, null); // #to_action
            }
            return true;
        } else { // e.g. not found index()
            return false;
        }
    }
441382
protected <T extends Request, U extends Response> CompletableFuture<U> forward(T request) {
    CompletableFuture<U> future = new CompletableFuture<>();
    context.getConnections().getConnection(context.getLeader().serverAddress()).whenComplete((connection, connectError) -> {
      if (connectError == null) {
        connection.<T, U>sendAndReceive(request).whenComplete((response, responseError) -> {
          if (responseError == null) {
            future.complete(response);
          } else {
            future.completeExceptionally(responseError);
          }
        });
      } else {
        future.completeExceptionally(connectError);
      }
    });
    return future;
  }
817746
function (request, response, next) {
                if (!next) {
                    next = makeDefaultNext(request, response);
                }
                try {
                    var url = request.url;
                    var questionIndex = url.indexOf("?");
                    var querystring = "";
                    if (questionIndex !== -1) {
                        // if there is a querystring, we'll just chop that part off
                        // it's still preserved in request.url, and should be handled
                        // by other middleware.
                        querystring = url.substring(questionIndex);
                        url = url.substring(0, questionIndex);
                    }
                    
                    var now = +new Date();
                    if (cacheExpirationTime < now) {
                        // time to reset the dynamic cache cache
                        
                        // Object.create(null) is used instead of {} so it doesn't have a prototype of Object.prototype
                        dynamicRouteCache = Object.create(null);
                        redirectCache = Object.create(null);
                        cacheExpirationTime = now + CACHE_CLEAR_TIME;
                    }
                    
                    var actualUrl = url;
                    var cachedResult = redirectCache[actualUrl];
                    if (cachedResult) {
                        movedPermanently(response, cachedResult + querystring);
                        return;
                    }
                    
                    var lowerMethod = request.method.toLowerCase();
                    if (url.length > 1 && url[url.length - 1] === "/") {
                        url = trimEndingSlashes(url);
                    }
                    var lowerUrl = url.toLowerCase();
                    var staticRoute = staticRoutes[lowerUrl];
                    var params;
                    var callback;
                    var descriptor;
                    var properUrl;
                    
                    if (staticRoute) {
                        properUrl = staticRoute.route;
                        if (properUrl !== actualUrl) {
                            redirectCache[actualUrl] = properUrl;
                            movedPermanently(response, properUrl + querystring);
                            return;
                        }
                        
                        descriptor = staticRoute.descriptor;
                        
                        // we found a static route
                        callback = descriptor[lowerMethod];
                        
                        if (!callback) {
                            // the URL exists, but does not have the provided method defined for it
                            methodNotAllowedHandler(request, response, next);
                            return;
                        }

                        params = emptyParams;
                    } else {
                        cachedResult = dynamicRouteCache[actualUrl];
                        if (cachedResult) {
                            descriptor = cachedResult.descriptor;
                            callback = descriptor[lowerMethod];
                            if (!callback) {
                                // the URL exists, but does not have the provided method defined for it
                                methodNotAllowedHandler(request, response, next);
                                return;
                            }
                            params = cachedResult.params;
                        } else {
                            searchDynamicRoutes:
                            for (var i = 0, len = dynamicRoutes.length; i < len; i += 1) {
                                var dynamicRoute = dynamicRoutes[i];
                                var prefix = dynamicRoute.prefix;
                            
                                if (prefix !== "/" && !startsWith(lowerUrl, prefix)) {
                                    continue;
                                }
                            
                                var routes = dynamicRoute.routes;
                                searchWithinPrefix:
                                for (var j = 0, lenJ = routes.length; j < lenJ; j += 1) {
                                    var route = routes[j];
                                    var match = route.regex.exec(url);
                                    if (!match) {
                                        continue;
                                    }
                                
                                    descriptor = route.descriptor;
                                    callback = descriptor[lowerMethod];
                                    if (!callback) {
                                        // the URL exists, but does not have the provided method defined for it
                                        methodNotAllowedHandler(request, response, next);
                                        return;
                                    }
                                
                                    var literals = route.literals;
                                    properUrl = literals[0];
                                    var argumentNames = route.argumentNames;
                                    var converters = route.converters;
                                    params = {};
                                    for (var k = 0, lenK = argumentNames.length; k < lenK; k += 1) {
                                        var unconvertedValue = match[k * 2 + 2];
                                        var convertedValue;
                                        try {
                                            convertedValue = converters[k](unconvertedValue);
                                        } catch (ex) {
                                            if (ex instanceof escort.ValidationError) {
                                                // if the converter explicitly throws a ValidationError, the route doesn't match.
                                                // thus, we need to keep searching for the correct route.
                                                callback = undefined;
                                                continue searchWithinPrefix;
                                            } else if (ex instanceof escort.CasingError) {
                                                unconvertedValue = ex.expectedCasing;
                                                convertedValue = converters[k](unconvertedValue); // guaranteed not to error
                                            } else {
                                                throw ex;
                                            }
                                        }
                                        properUrl += unconvertedValue;
                                        properUrl += literals[k + 1] || "";
                                        params[argumentNames[k]] = convertedValue;
                                    }
                                    if (route.hasEndingSlash) {
                                        properUrl += "/";
                                    }
                            
                                    if (actualUrl !== properUrl) {
                                        redirectCache[actualUrl] = properUrl;
                                        movedPermanently(response, properUrl + querystring);
                                        return;
                                    }
                                    
                                    // params needs to be frozen since it will be potentially used in later requests through the dynamic route caching system
                                    freeze(params);
                                    dynamicRouteCache[actualUrl] = {
                                        descriptor: descriptor,
                                        params: params
                                    };
                                    
                                    // we're done, so we need to break out of the outer for loop
                                    break searchDynamicRoutes;
                                }
                            }
                        }
                    }
                    
                    if (!callback) {
                        // route was unable to be located
                        if (notFoundHandler) {
                            notFoundHandler(request, response, next);
                        } else {
                            next();
                        }
                        return;
                    }
                    
                    // set params on request as well as pass it into the callback.
                    request.params = params;
                    // the descriptor is passed in as "this" so that the user can do this.post(request, response) from their get callback.
                    callback.call(descriptor, request, response, params, !notFoundHandler ? next : function (err) {
                        if (err) {
                            next(err);
                        } else {
                            notFoundHandler(request, response, next);
                        }
                    });
                } catch (err) {
                    next(err);
                }
            }
426361
@Override
    public URLStreamHandler createURLStreamHandler(final String protocol) {
        if (null == protocol) {
            throw new IllegalArgumentException("null protocol not allowed");
        }
        if (logger.isTraceEnabled()) {
            logger.trace("need to create URLStreamHandler for protocol {}", protocol);
        }

        final String proto = protocol.toLowerCase();
        if (PROTO_HTTP.equals(proto) || PROTO_HTTPS.equals(proto)) {
            return new URLStreamHandler() {
                @Override
                protected URLConnection openConnection(final URL url) throws IOException {
                    if (logger.isTraceEnabled()) {
                        logger.trace("should open connection to {}", url.toExternalForm());
                    }

                    // URLConnection only has a protected ctor, so we need to go through the URL ctor with the matching handler
                    final URLConnection defaultUrlConnection =
                            new URL(protocol, url.getHost(), url.getPort(), url.getFile(), handlers.get(protocol))
                                    .openConnection();

                    if (!cache.urlShouldBeCached(url)) {
                        if (logger.isTraceEnabled()) {
                            logger.trace("not using cache for {}", url);
                        }
                        return defaultUrlConnection;
                    }

                    final Path cacheFile = cache.filenameForURL(url);
                    // now wrap the defaultUrlConnection
                    if (cache.isCached(url)) {
                        // if cached, always use http connection to prevent ssl handshake. As we are reading from the
                        // cache, this is enough
                        return new CachingHttpURLConnection(cache, (HttpURLConnection) defaultUrlConnection);
                    } else {
                        switch (proto) {
                            case PROTO_HTTP:
                                return new CachingHttpURLConnection(cache, (HttpURLConnection) defaultUrlConnection);
                            case PROTO_HTTPS:
                                return new CachingHttpsURLConnection(cache, (HttpsURLConnection) defaultUrlConnection);
                        }
                    }
                    throw new IOException("no matching handler");
                }

                @Override
                protected URLConnection openConnection(final URL u, final Proxy p) throws IOException {
                    if (logger.isTraceEnabled()) {
                        logger.trace("should open connection to {} via {}", u.toExternalForm(), p);
                    }
                    // URLConnection only has a protected ctor, so we need to go through the URL ctor with the
                    // matching handler to get a default implementation of the needed URLStreamHandler
                    final URLConnection defaultUrlConnection =
                            new URL(protocol, u.getHost(), u.getPort(), u.getFile(), handlers.get(protocol))
                                    .openConnection(p);

                    return defaultUrlConnection;
                }
            };
        }
        // return null to use default ones
        return null;
    }
647286
def dispatch_request(self):
        """"""

        req = _request_ctx_stack.top.request
        app = current_app

        # Return flask's default options response. See issue #40
        if req.method == "OPTIONS":
            return app.make_default_options_response()

        if req.routing_exception is not None:
            app.raise_routing_exception(req)

        # The routing rule has some handy attributes to extract how Flask found
        # this endpoint
        rule = req.url_rule

        # Wrap the real view_func
        view_func = self.wrap_view_func(
            app, rule, req, app.view_functions[rule.endpoint], req.view_args
        )

        return view_func(**req.view_args)