Dispatches the current HTTP request (if there is any).

@SuppressWarnings("PHPMD.StaticAccess")

@return null

@throws \RuntimeException if configure has not been called before
@throws \Exception
540141
public function dispatch()
    {
        $this->assertConfigureHasBeenCalled();

        $request = Request::createFromGlobals();
        $response = $this->getApplicationKernel()->handle($request);
        $response->send();
        $this->getApplicationKernel()->terminate($request, $response);

        return null;
    }
165398
public static function dispatch()
    {
        $uri = strtok($_SERVER["REQUEST_URI"],'?');
        $qs = parse_url($_SERVER["REQUEST_URI"], PHP_URL_QUERY);
        $method = $_SERVER['REQUEST_METHOD'];
        
        
        foreach (self::$routes as $name=>$route) {


            $route  = self::parsePattern($route);

            $matched = array();
            if ($route=='' || preg_match('#' . $route . '#', $uri, $matched) && (self::$methods[$name] == 'ANY' || self::$methods[$name] == $method)) {
                
                array_shift($matched);

                if (self::$qs[$name]!='' && preg_match('#' . self::$qs[$name] . '#', $qs, $qsmatched)) {

                    array_shift($qsmatched);

                    $matched = array_merge($matched, $qsmatched);
                    self::$catched[] = $name;
                    BurpEvent::listen($name, self::$callbacks[$name]);
                    BurpEvent::queue($name, $matched);

                } elseif (self::$qs[$name] == '') {
                    self::$catched[] = $name;
                    BurpEvent::listen($name, self::$callbacks[$name]);
                    BurpEvent::queue($name, $matched);
                }
            }

        }

        //call missing if needed
        if (!is_null(self::$missing_callback) ) {
            $diff = array_diff(self::$tocatch, self::$catched);
            if (count($diff) >= count(self::$tocatch)) {
                call_user_func(self::$missing_callback);
                BurpEvent::listen('missing', self::$callbacks[$name]);
                BurpEvent::fire('missing');

            }

        }

        BurpEvent::flushAll();
    }
159832
public function httpRequest()
    {
        if ($this->httpRequest === null) {
            throw new RuntimeException(sprintf(
                'PSR-7 HTTP Request is not defined for "%s"',
                get_class($this)
            ));
        }

        return $this->httpRequest;
    }
1264366
public static function handleRequest()
    {
        // save static class
        static::$calledClass = get_called_class();

        // handle JSON requests
        if (static::peekPath() == 'json') {
            // check access for API response modes
            static::$responseMode = static::shiftPath();
            if (in_array(static::$responseMode, ['json','jsonp'])) {
                if (!static::checkAPIAccess()) {
                    return static::throwAPIUnAuthorizedError();
                }
            }
        }

        return static::handleRecordsRequest();
    }
578316
public function run()
    {
        $this->init();
        try {
            $this->bootstrap();
            $this->route();
            $this->dispatch();
        } catch (Exception $e) {
            if (APPLICATION_ENV == self::ENV_DEV) {
                var_dump($e);
            } else {
                throw $e;
            }
        }
        return $this;
    }
1036008
protected function call()
    {
        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_RETURNTRANSFER      => 1,
            CURLOPT_URL                 => $this->requestUrl[$this->format].$this->param,
            CURLOPT_SSL_VERIFYPEER      => false,
            CURLOPT_FAILONERROR         => true,
        ));

        $request = curl_exec($curl);

        if (empty($request)) {
            throw new \RuntimeException('cURL request retuened following error: '.curl_error($curl) );
        }

        curl_close($curl);

        return $request;
    }
907329
protected static function currentRequest(HTTPRequest $request = null)
    {
        // Ensure we only use a registered HTTPRequest and don't
        // incidentally construct a singleton
        if (!$request && Injector::inst()->has(HTTPRequest::class)) {
            $request = Injector::inst()->get(HTTPRequest::class);
        }
        return $request;
    }
350776
public function init()
    {
        $stream = @fopen($this->config['url'], 'a');
        if (!$stream) {
            throw new \RuntimeException(sprintf("Couldn't open resource '%s'", $this->config['url']));
        }

        $this->stream = $stream;

        if (!empty($this->config['lock']) && $this->config['lock'] === true && stream_supports_lock($this->stream)) {
            $this->useLocks = true;
        }
    }
466955
public function sendRequest()
    {
        if ($this->getError()->hasError()) {
            return;
        }

        if (class_exists($this->dispatcher)) {
            $dispatcherClass = $this->dispatcher;
            $dispatcher = new $dispatcherClass($this->instance->getQuery());
            if ($dispatcher instanceof AbstractDispatcher) {
                try {
                    $client = new \SoapCLient($this->getUrl(), array('trace' => 1));

                    $config = $this->config->getRawConfig();
                    $sql = $this->instance->getQuery()->toString();
                    $limit = $this->instance->getQuery()->getLimit();
                    $offset = $this->instance->getQuery()->getOffset();
                    $single = $this->instance->getQuery()->isSingle();

                    if ($this->method == 'getAvailableDrivers') {
                        $this->availableDrivers = $client->getAvailableDrivers();
                    } elseif ($this->method == 'getServerVersion') {
                        $res = $client->getServerVersion();
                        $this->serverVersion = isset($res['version']) ? $res['version'] : null;
                    } else {
                        $response = $client->getResult($config, $sql, $limit, $offset, $single, $this->getKey(), 'array');
                        $dispatcher->dispatch($response);
                    }
                } catch (\SoapFault $e) {
                    $this->getError()->setMessage($e->getMessage());
                } catch (\Exception $e) {
                    $this->getError()->setMessage('Error server response');
                }
            } else {
                $this->getError()->setMessage(sprintf(
                    'Dispatcher class must be instance of %s, %s given',
                    AbstractDispatcher::class,
                    (string) $this->dispatcher
                ));
            }
        } else {
            $this->getError()->setMessage(sprintf('Class %s not found', (string) $this->dispatcher));
        }
    }
997014
public function handleRequest()
    {
        $request = $this->prepareRequest();
        $version = $request['version'];
        $queryConfiguration = $request['queryConfiguration'];

        $data = $this->provider->process();
        return $version->createResponse($data, $queryConfiguration, $this->columnConfigurations);
    }
122485
public function dispatch() {

		$this->response = new stdClass();

		// blank headers
		$this->curl_headers = '';

		$start_time = microtime( true );

		// send request + save raw response body
		$this->response->body = curl_exec( $this->ch );

		// request duration
		$this->request->duration = round( microtime( true ) - $start_time, 5 );

		// response code
		$this->response->code = curl_getinfo( $this->ch, CURLINFO_HTTP_CODE );

		// response headers
		$this->response->headers = $this->get_response_headers();

		curl_close( $this->ch );

		$parsed_response = $this->get_parsed_response( $this->response->body );

		// check for invalid JSON
		if ( null === $parsed_response ) {

			throw new WC_API_Client_HTTP_Exception( sprintf( 'Invalid JSON returned for %s.', $this->request->url ), $this->response->code, $this->request, $this->response );
		}

		// any non-200/201/202 response code indicates an error
		if ( ! in_array( $this->response->code, array( '200', '201', '202' ) ) ) {

			// error message/code is nested sometimes
			if ( $this->json_decode_as_array ) {

				list( $error_message, $error_code ) = is_array( $parsed_response['errors'] ) ? array(
					$parsed_response['errors'][0]['message'],
					$parsed_response['errors'][0]['code']
				) : array(
					$parsed_response['errors']['message'],
					$parsed_response['errors']['code']
				);

			} else {

				list( $error_message, $error_code ) = is_array( $parsed_response->errors ) ? array(
					$parsed_response->errors[0]->message,
					$parsed_response->errors[0]->code
				) : array(
					$parsed_response->errors->message,
					$parsed_response->errors->code
				);
			}

			throw new WC_API_Client_HTTP_Exception( sprintf( 'Error: %s [%s]', $error_message, $error_code ), $this->response->code, $this->request, $this->response);
		}

		return $this->build_result( $parsed_response );
	}
519438
public final function request()
    {
        if ($this->request == null){
            $this->request = $this->phpContext->createRequest();
        }

        return $this->request;
    }
290298
public static function dispatch()
    {

        if (is_null(self::$route)) die(Utils::colorize("No console route found", 'FAILURE'));

        // Grab the controller name and method call
        $segments = explode('@', self::$route);

        $controller = $segments[0];
        // Compiled action name
        $action = $segments[1] . 'Action';

        $object = new $controller();
        if (!method_exists($object, $action)) die(Utils::colorize("No action '{$segments[1]}' find in {$controller}!", 'FAILURE'));

        call_user_func_array(array($controller, $action), self::$parameters);
    }
435464
public function dispatch()
    {
        $request  = Container::getRequest();
        $response = Container::getResponse();
        
        PluginManager::handleApplicationPlugins(PluginManager::STEP_BEFORE_DISPATCH_LOOP);
        //self::debug('Begin dispatch loop...');
        while (!$this->dispatched) {
            
            try {
                PluginManager::handleApplicationPlugins(PluginManager::STEP_BEFORE_ACTION);
                //self::debug('Begin dispatch ' . $request->getController() . '::' . $request->getAction() . ' [' . json_encode($request->getParams()) . ']');
                $this->dispatchProcess($request, $response);
                //self::debug('End dispatch ' . $request->getController() . '::' . $request->getAction() . ' [' . json_encode($request->getParams()) . ']');
                PluginManager::handleApplicationPlugins(PluginManager::STEP_AFTER_ACTION);
            }
            catch (Exception $e) {
                if ($request->getController(false) == 'event' 
                 && $request->getAction(false) == 'error') {
                    throw $e;
                }
                Container::getView()->addValue('exception', $e);
                $this->renderView = true;
                $request->setController('event')->setAction('error');
                $this->setDispatched(false);
            }
        }
        PluginManager::handleApplicationPlugins(PluginManager::STEP_AFTER_DISPATCH_LOOP);
        self::debug('End dispatch loop');
        if ($this->dispatched && $this->renderLayout) {
            $layout = Container::getConfig()->getConfig('layout');
            if ($layout !== null) {
                if (!file_exists($layout)) {
                    throw new ArchException('Layout file ' . $layout . ' not found');
                }
                $response->setBody(Container::getLayout(true)->render($layout));
            }
        }
        if ($this->renderResponse) {
            $response->fixHeaders()->putTypeHeadersInResponse();
            foreach ($response->getHeaders() as $header) {
                header($header);
            }
            $response->executeCallback();
            if ($response->hasBody()) {
                echo $response->getBody();
            }
        }
        return $this;
    }
365165
public function detect() {
		// Deprecated - the vendor libs are far more accurate and up to date
		if (!$this->_config['engine']) {
			if (isset($this->Controller->RequestHandler)) {
				return $this->Controller->getRequest()->is('mobile') || $this->Controller->RequestHandler->accepts('wap');
			}
			return $this->Controller->getRequest()->is('mobile');
		}
		if (is_callable($this->_config['engine'])) {
			return call_user_func($this->_config['engine']);
		}
		throw new RuntimeException(sprintf('Engine %s not available', $this->_config['engine']));
	}
921630
public function dispatch()
	{
		if(!self::$isDispatched){
		    if (PHP_SAPI == 'cli') {
		        $this->dispatchCli();
		    } else {
                $this->dispatchHttp();
		    }
            self::$isDispatched = true;
        }
    }
529049
public function loadConfig()
    {
        $result = $this->configStorage->lock();
        if ($result === false) {
            throw new \RuntimeException('Failed to lock the configStorage');
        }
        try {
            $result = $this->configStorage->load();
        } catch (\RuntimeException $e) {
            $this->configStorage->clear();
            throw $e;
        } finally {
            $this->configStorage->unlock();
        }

        $this->config = $result;
        return true;
    }