private void dispatchOutsideContainer ( SipServletRequestImpl sipServletRequest ) throws DispatcherException { final Request request = ( Request ) sipServletRequest . getMessage ( ) ; if ( logger . isInfoEnabled ( ) ) { logger . info ( "Dispatching the request event outside the container" ) ; } //check if the request point to another domain if ( request . getRequestURI ( ) instanceof TelURL || // https://github.com/RestComm/sip-servlets/issues/108 ! ( request . getRequestURI ( ) instanceof javax . sip . address . SipURI ) ) { throw new DispatcherException ( Response . SERVER_INTERNAL_ERROR , "cannot dispatch a request with a tel url or generic request uri outside the container " ) ; } javax . sip . address . SipURI sipRequestUri = ( javax . sip . address . SipURI ) request . getRequestURI ( ) ; String host = sipRequestUri . getHost ( ) ; int port = sipRequestUri . getPort ( ) ; String transport = JainSipUtils . findTransport ( request ) ; boolean isAnotherDomain = sipApplicationDispatcher . isExternal ( host , port , transport ) ; ListIterator < String > routeHeaders = sipServletRequest . getHeaders ( RouteHeader . NAME ) ; if ( isAnotherDomain || routeHeaders . hasNext ( ) ) { try { forwardRequestStatefully ( sipServletRequest , SipSessionRoutingType . PREVIOUS_SESSION , SipRouteModifier . NO_ROUTE ) ; } catch ( Exception e ) { throw new DispatcherException ( Response . SERVER_INTERNAL_ERROR , "Unexpected Exception while trying to forward statefully the following initial request " + request , e ) ; } } else { // the Request-URI does not point to another domain, and there is no Route header, // the container should not send the request as it will cause a loop. // Instead, the container must reject the request with 404 Not Found final response with no Retry-After header. throw new DispatcherException ( Response . NOT_FOUND , "the Request-URI does not point to another domain, and there is no Route header," + "the container should not send the request as it will cause a loop. " + "Instead, the container must reject the request with 404 Not Found final response with no Retry-After header. You may want to check your dar configuration file to see if the request can be handled or make sure you use the correct Application Router jar." ) ; } }
Dispatch a request outside the container