public static function instance(&$uri = TRUE) { if (!Request::$instance) { if (!empty($_SERVER['HTTPS']) and filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN)) { Request::$protocol = 'https'; } if (isset($_SERVER['REQUEST_METHOD'])) { Request::$method = $_SERVER['REQUEST_METHOD']; } if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') { Request::$is_ajax = TRUE; } Request::$client_ip = self::get_client_ip(); if (Request::$method !== 'GET' and Request::$method !== 'POST') { parse_str(file_get_contents('php://input'), $_POST); } if (isset($_SERVER['HTTP_USER_AGENT'])) { Request::$user_agent = $_SERVER['HTTP_USER_AGENT']; } if (isset($_SERVER['HTTP_REFERER'])) { Request::$referrer = $_SERVER['HTTP_REFERER']; } if ($uri === TRUE) { $uri = Request::detect_uri(); } $uri = preg_replace('#//+#', '/', $uri); $uri = preg_replace('#\\.[\\s./]*/#', '', $uri); Request::$instance = new Request($uri); } return Request::$instance; }
public function setUp() { parent::setUp(); $_COOKIE = array(); $_SESSION = array(); Request::$client_ip = '8.8.8.8'; Request::$user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19'; $this->auth = new Auth_Jam_Test(Kohana::$config->load('auth')); $this->auth->session()->restart(); Database::instance(Kohana::TESTING)->begin(); }
public static function factory($uri = TRUE, $client_params = array(), $allow_external = TRUE, $injected_routes = array()) { if (!Request::$initial) { $protocol = HTTP::$protocol; if (isset($_SERVER['REQUEST_METHOD'])) { $method = $_SERVER['REQUEST_METHOD']; } else { $method = HTTP_Request::GET; } if (!empty($_SERVER['HTTPS']) and filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN) or isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' and in_array($_SERVER['REMOTE_ADDR'], Request::$trusted_proxies)) { $secure = TRUE; } if (isset($_SERVER['HTTP_REFERER'])) { $referrer = $_SERVER['HTTP_REFERER']; } if (isset($_SERVER['HTTP_USER_AGENT'])) { Request::$user_agent = $_SERVER['HTTP_USER_AGENT']; } if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { $requested_with = $_SERVER['HTTP_X_REQUESTED_WITH']; } if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) and isset($_SERVER['REMOTE_ADDR']) and in_array($_SERVER['REMOTE_ADDR'], Request::$trusted_proxies)) { $client_ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); Request::$client_ip = array_shift($client_ips); unset($client_ips); } elseif (isset($_SERVER['HTTP_CLIENT_IP']) and isset($_SERVER['REMOTE_ADDR']) and in_array($_SERVER['REMOTE_ADDR'], Request::$trusted_proxies)) { $client_ips = explode(',', $_SERVER['HTTP_CLIENT_IP']); Request::$client_ip = array_shift($client_ips); unset($client_ips); } elseif (isset($_SERVER['REMOTE_ADDR'])) { // The remote IP address Request::$client_ip = $_SERVER['REMOTE_ADDR']; } if ($method !== HTTP_Request::GET) { // Ensure the raw body is saved for future use $body = file_get_contents('php://input'); } if ($uri === TRUE) { // Attempt to guess the proper URI $uri = Request::detect_uri(); } $cookies = array(); if ($cookie_keys = array_keys($_COOKIE)) { foreach ($cookie_keys as $key) { $cookies[$key] = Cookie::get($key); } } // Create the instance singleton Request::$initial = $request = new Request($uri, $client_params, $allow_external, $injected_routes); // Store global GET and POST data in the initial request only $request->protocol($protocol)->query($_GET)->post($_POST); if (isset($secure)) { // Set the request security $request->secure($secure); } if (isset($method)) { // Set the request method $request->method($method); } if (isset($referrer)) { // Set the referrer $request->referrer($referrer); } if (isset($requested_with)) { // Apply the requested with variable $request->requested_with($requested_with); } if (isset($body)) { // Set the request body (probably a PUT type) $request->body($body); } if (isset($cookies)) { $request->cookie($cookies); } } else { $request = new Request($uri, $client_params, $allow_external, $injected_routes); } return $request; }
/** * Creates a new request object for the given URI. New requests should be * created using the [Request::instance] or [Request::factory] methods. * * $request = Request::factory($uri); * * If $cache parameter is set, the response for the request will attempt to * be retrieved from the cache. * * @param string $uri URI of the request * @param Cache $cache * @param array $injected_routes an array of routes to use, for testing * @return void * @throws Request_Exception * @uses Route::all * @uses Route::matches */ public static function factory($uri = TRUE, HTTP_Cache $cache = NULL, $injected_routes = array()) { // If this is the initial request if (!Request::$initial) { if (Kohana::$is_cli) { // Default protocol for command line is cli:// $protocol = 'cli'; // Get the command line options $options = CLI::options('uri', 'method', 'get', 'post', 'referrer'); if (isset($options['uri'])) { // Use the specified URI $uri = $options['uri']; } elseif ($uri === TRUE) { $uri = ''; } if (isset($options['method'])) { // Use the specified method $method = strtoupper($options['method']); } else { // Default to GET requests $method = HTTP_Request::GET; } if (isset($options['get'])) { // Overload the global GET data parse_str($options['get'], $_GET); } if (isset($options['post'])) { // Overload the global POST data parse_str($options['post'], $_POST); } if (isset($options['referrer'])) { $referrer = $options['referrer']; } } else { if (isset($_SERVER['SERVER_PROTOCOL'])) { $protocol = $_SERVER['SERVER_PROTOCOL']; } else { $protocol = HTTP::$protocol; } if (isset($_SERVER['REQUEST_METHOD'])) { // Use the server request method $method = $_SERVER['REQUEST_METHOD']; } else { // Default to GET requests $method = HTTP_Request::GET; } if (!empty($_SERVER['HTTPS']) and filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN)) { // This request is secure $secure = TRUE; } if (isset($_SERVER['HTTP_REFERER'])) { // There is a referrer for this request $referrer = $_SERVER['HTTP_REFERER']; } if (isset($_SERVER['HTTP_USER_AGENT'])) { // Browser type Request::$user_agent = $_SERVER['HTTP_USER_AGENT']; } if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { // Typically used to denote AJAX requests $requested_with = $_SERVER['HTTP_X_REQUESTED_WITH']; } if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) and isset($_SERVER['REMOTE_ADDR']) and in_array($_SERVER['REMOTE_ADDR'], Request::$trusted_proxies)) { // Use the forwarded IP address, typically set when the // client is using a proxy server. // Format: "X-Forwarded-For: client1, proxy1, proxy2" $client_ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); Request::$client_ip = array_shift($client_ips); unset($client_ips); } elseif (isset($_SERVER['HTTP_CLIENT_IP']) and isset($_SERVER['REMOTE_ADDR']) and in_array($_SERVER['REMOTE_ADDR'], Request::$trusted_proxies)) { // Use the forwarded IP address, typically set when the // client is using a proxy server. $client_ips = explode(',', $_SERVER['HTTP_CLIENT_IP']); Request::$client_ip = array_shift($client_ips); unset($client_ips); } elseif (isset($_SERVER['REMOTE_ADDR'])) { // The remote IP address Request::$client_ip = $_SERVER['REMOTE_ADDR']; } if ($method !== HTTP_Request::GET) { // Ensure the raw body is saved for future use $body = file_get_contents('php://input'); } if ($uri === TRUE) { // Attempt to guess the proper URI $uri = Request::detect_uri(); } } // Create the instance singleton Request::$initial = $request = new Request($uri, $cache); // Store global GET and POST data in the initial request only $request->protocol($protocol)->query($_GET)->post($_POST); if (isset($secure)) { // Set the request security $request->secure($secure); } if (isset($method)) { // Set the request method $request->method($method); } if (isset($referrer)) { // Set the referrer $request->referrer($referrer); } if (isset($requested_with)) { // Apply the requested with variable $request->requested_with($requested_with); } if (isset($body)) { // Set the request body (probably a PUT type) $request->body($body); } } else { $request = new Request($uri, $cache, $injected_routes); } return $request; }
/** * Main request singleton instance. If no URI is provided, the URI will * be automatically detected using PATH_INFO, REQUEST_URI, or PHP_SELF. * * $request = Request::instance(); * * @param string URI of the request * @return Request */ public static function instance(&$uri = TRUE) { if (!Request::$instance) { if (Kohana::$is_cli) { // Default protocol for command line is cli:// Request::$protocol = 'cli'; // Get the command line options $options = CLI::options('uri', 'method', 'get', 'post'); if (isset($options['uri'])) { // Use the specified URI $uri = $options['uri']; } if (isset($options['method'])) { // Use the specified method Request::$method = strtoupper($options['method']); } if (isset($options['get'])) { // Overload the global GET data parse_str($options['get'], $_GET); } if (isset($options['post'])) { // Overload the global POST data parse_str($options['post'], $_POST); } } else { if (isset($_SERVER['REQUEST_METHOD'])) { // Use the server request method Request::$method = $_SERVER['REQUEST_METHOD']; } if (!empty($_SERVER['HTTPS']) and filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN)) { // This request is secure Request::$protocol = 'https'; } if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') { // This request is an AJAX request Request::$is_ajax = TRUE; } if (isset($_SERVER['HTTP_REFERER'])) { // There is a referrer for this request Request::$referrer = $_SERVER['HTTP_REFERER']; } if (isset($_SERVER['HTTP_USER_AGENT'])) { // Set the client user agent Request::$user_agent = $_SERVER['HTTP_USER_AGENT']; } if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { // Use the forwarded IP address, typically set when the // client is using a proxy server. Request::$client_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { // Use the forwarded IP address, typically set when the // client is using a proxy server. Request::$client_ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (isset($_SERVER['REMOTE_ADDR'])) { // The remote IP address Request::$client_ip = $_SERVER['REMOTE_ADDR']; } if (Request::$method !== 'GET' and Request::$method !== 'POST') { // Methods besides GET and POST do not properly parse the form-encoded // query string into the $_POST array, so we overload it manually. parse_str(file_get_contents('php://input'), $_POST); } if ($uri === TRUE) { if (!empty($_SERVER['PATH_INFO'])) { // PATH_INFO does not contain the docroot or index $uri = $_SERVER['PATH_INFO']; } else { // REQUEST_URI and PHP_SELF include the docroot and index if (isset($_SERVER['REQUEST_URI'])) { // REQUEST_URI includes the query string, remove it $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); } elseif (isset($_SERVER['PHP_SELF'])) { $uri = $_SERVER['PHP_SELF']; } elseif (isset($_SERVER['REDIRECT_URL'])) { $uri = $_SERVER['REDIRECT_URL']; } else { // If you ever see this error, please report an issue at and include a dump of $_SERVER // http://dev.kohanaphp.com/projects/kohana3/issues throw new Kohana_Exception('Unable to detect the URI using PATH_INFO, REQUEST_URI, or PHP_SELF'); } // Get the path from the base URL, including the index file $base_url = parse_url(Kohana::$base_url, PHP_URL_PATH); if (strpos($uri, $base_url) === 0) { // Remove the base URL from the URI $uri = substr($uri, strlen($base_url)); } if (Kohana::$index_file and strpos($uri, Kohana::$index_file) === 0) { // Remove the index file from the URI $uri = substr($uri, strlen(Kohana::$index_file)); } } } } // Reduce multiple slashes to a single slash $uri = preg_replace('#//+#', '/', $uri); // Remove all dot-paths from the URI, they are not valid $uri = preg_replace('#\\.[\\s./]*/#', '', $uri); // Create the instance singleton Request::$instance = Request::$current = new Request($uri); // Add the default Content-Type header Request::$instance->headers['Content-Type'] = 'text/html; charset=' . Kohana::$charset; } return Request::$instance; }
/** * Main request singleton instance. If no URI is provided, the URI will * be automatically detected. * * $request = Request::instance(); * * @param string URI of the request * @return Request * @uses Request::detect_uri */ public static function instance( & $uri = TRUE) { if ( ! Request::$instance) { if (Kohana::$is_cli) { // Default protocol for command line is cli:// Request::$protocol = 'cli'; // Get the command line options $options = CLI::options('uri', 'method', 'get', 'post'); if (isset($options['uri'])) { // Use the specified URI $uri = $options['uri']; } if (isset($options['method'])) { // Use the specified method Request::$method = strtoupper($options['method']); } if (isset($options['get'])) { // Overload the global GET data parse_str($options['get'], $_GET); } if (isset($options['post'])) { // Overload the global POST data parse_str($options['post'], $_POST); } } else { if (isset($_SERVER['REQUEST_METHOD'])) { // Use the server request method Request::$method = $_SERVER['REQUEST_METHOD']; } if ( ! empty($_SERVER['HTTPS']) AND filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN)) { // This request is secure Request::$protocol = 'https'; } if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') { // This request is an AJAX request Request::$is_ajax = TRUE; } if (isset($_SERVER['HTTP_REFERER'])) { // There is a referrer for this request Request::$referrer = $_SERVER['HTTP_REFERER']; } if (isset($_SERVER['HTTP_USER_AGENT'])) { // Set the client user agent Request::$user_agent = $_SERVER['HTTP_USER_AGENT']; } if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { // Use the forwarded IP address, typically set when the // client is using a proxy server. Request::$client_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { // Use the forwarded IP address, typically set when the // client is using a proxy server. Request::$client_ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (isset($_SERVER['REMOTE_ADDR'])) { // The remote IP address Request::$client_ip = $_SERVER['REMOTE_ADDR']; } if (Request::$method !== 'GET' AND Request::$method !== 'POST') { // Methods besides GET and POST do not properly parse the form-encoded // query string into the $_POST array, so we overload it manually. parse_str(file_get_contents('php://input'), $_POST); } if ($uri === TRUE) { $uri = Request::detect_uri(); } } // Reduce multiple slashes to a single slash $uri = preg_replace('#//+#', '/', $uri); // Remove all dot-paths from the URI, they are not valid $uri = preg_replace('#\.[\s./]*/#', '', $uri); // Create the instance singleton Request::$instance = Request::$current = new Request($uri); // Add the default Content-Type header Request::$instance->headers['Content-Type'] = 'text/html; charset='.Kohana::$charset; } return Request::$instance; }
/** * @param string $uri * @param array $client_params * @param bool $allow_external * @param array $injected_routes * @internal param \HTTP_Cache $cache * @return \HAPI_Request|\Request|void */ public static function factory($uri = '', $client_params = array(), $allow_external = TRUE, $injected_routes = array()) { // If this is the initial request if (!Request::$initial) { if (isset($_SERVER['SERVER_PROTOCOL'])) { $protocol = $_SERVER['SERVER_PROTOCOL']; } else { $protocol = HTTP::$protocol; } if (isset($_SERVER['REQUEST_METHOD'])) { // Use the server request method $method = $_SERVER['REQUEST_METHOD']; } else { // Default to GET requests $method = HTTP_Request::GET; } if (!empty($_SERVER['HTTPS']) and filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN)) { // This request is secure $secure = TRUE; } if (isset($_SERVER['HTTP_REFERER'])) { // There is a referrer for this request $referrer = $_SERVER['HTTP_REFERER']; } if (isset($_SERVER['HTTP_USER_AGENT'])) { // Browser type Request::$user_agent = $_SERVER['HTTP_USER_AGENT']; } if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { // Typically used to denote AJAX requests $requested_with = $_SERVER['HTTP_X_REQUESTED_WITH']; } if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) and isset($_SERVER['REMOTE_ADDR']) and in_array($_SERVER['REMOTE_ADDR'], Request::$trusted_proxies)) { // Use the forwarded IP address, typically set when the // client is using a proxy server. // Format: "X-Forwarded-For: client1, proxy1, proxy2" $client_ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); Request::$client_ip = array_shift($client_ips); unset($client_ips); } elseif (isset($_SERVER['HTTP_CLIENT_IP']) and isset($_SERVER['REMOTE_ADDR']) and in_array($_SERVER['REMOTE_ADDR'], Request::$trusted_proxies)) { // Use the forwarded IP address, typically set when the // client is using a proxy server. $client_ips = explode(',', $_SERVER['HTTP_CLIENT_IP']); Request::$client_ip = array_shift($client_ips); unset($client_ips); } elseif (isset($_SERVER['REMOTE_ADDR'])) { // The remote IP address Request::$client_ip = $_SERVER['REMOTE_ADDR']; } if ($method !== HTTP_Request::GET) { // Ensure the raw body is saved for future use $body = file_get_contents('php://input'); } $cookies = array(); if ($cookie_keys = array_keys($_COOKIE)) { foreach ($cookie_keys as $key) { $cookies[$key] = Cookie::get($key); } } // Create the instance singleton Request::$initial = $request = new Request($uri, $client_params, $allow_external, $injected_routes); // Store global GET and POST data in the initial request only $request->protocol($protocol)->query($_GET)->post($_POST); if (isset($secure)) { // Set the request security $request->secure($secure); } if (isset($method)) { // Set the request method $request->method($method); } if (isset($referrer)) { // Set the referrer $request->referrer($referrer); } if (isset($requested_with)) { // Apply the requested with variable $request->requested_with($requested_with); } if (isset($body)) { // Set the request body (probably a PUT type) $request->body($body); } if (isset($cookies)) { $request->cookie($cookies); } } else { $request = new HAPI_Request($uri, $client_params, $allow_external, $injected_routes); } return $request; }
/** * Main request singleton instance. If no URI is provided, the URI will * be automatically detected using PATH_INFO, REQUEST_URI, or PHP_SELF. * * $request = Request::instance(); * * @param string URI of the request * @return Request */ public static function instance($uri = TRUE) { if (!Request::$instance) { if (isset($_SERVER['REQUEST_METHOD'])) { // Use the server request method Request::$method = $_SERVER['REQUEST_METHOD']; } if (!empty($_SERVER['HTTPS']) and filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN)) { // This request is secure Request::$protocol = 'https'; } if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') { // This request is an AJAX request Request::$is_ajax = TRUE; } if (isset($_SERVER['HTTP_REFERER'])) { // There is a referrer for this request Request::$referrer = $_SERVER['HTTP_REFERER']; } if (isset($_SERVER['HTTP_USER_AGENT'])) { // Set the client user agent Request::$user_agent = $_SERVER['HTTP_USER_AGENT']; } if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { // Use the forwarded IP address, typically set when the // client is using a proxy server. Request::$client_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { // Use the forwarded IP address, typically set when the // client is using a proxy server. Request::$client_ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (isset($_SERVER['REMOTE_ADDR'])) { // The remote IP address Request::$client_ip = $_SERVER['REMOTE_ADDR']; } if (Request::$method !== 'GET' and Request::$method !== 'POST') { // Methods besides GET and POST do not properly parse the form-encoded // query string into the $_POST array, so we overload it manually. parse_str(file_get_contents('php://input'), $_POST); } if ($uri === TRUE) { // If the route wasn't passed, just generate the route from $_POST or $_GET values $uri = array_merge(JRequest::get('get'), JRequest::get('post')); } // Set the default request client $client = JFactory::getApplication()->isAdmin() ? 'admin' : 'site'; // Create the instance singleton Request::$instance = Request::$current = new Request($uri, $client); } return Request::$instance; }
public static function factory($uri = TRUE, Cache $cache = NULL) { // If this is the initial request if (!Request::$initial) { if (Kohana::$is_cli) { // Default protocol for command line is cli:// $protocol = 'cli'; // Get the command line options $options = CLI::options('uri', 'method', 'get', 'post', 'referrer'); if (isset($options['uri'])) { // Use the specified URI $uri = $options['uri']; } if (isset($options['method'])) { // Use the specified method $method = strtoupper($options['method']); } else { $method = 'GET'; } if (isset($options['get'])) { // Overload the global GET data parse_str($options['get'], $_GET); } if (isset($options['post'])) { // Overload the global POST data parse_str($options['post'], $_POST); } if (isset($options['referrer'])) { $referrer = $options['referrer']; } else { $referrer = NULL; } } else { if (isset($_SERVER['REQUEST_METHOD'])) { // Use the server request method $method = $_SERVER['REQUEST_METHOD']; } else { // Default to GET $method = Http_Request::GET; } if (!empty($_SERVER['HTTPS']) and filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN)) { // This request is secure $protocol = 'https'; } else { $protocol = 'http'; } if (isset($_SERVER['HTTP_REFERER'])) { // There is a referrer for this request $referrer = $_SERVER['HTTP_REFERER']; } else { $referrer = NULL; } if (isset($_SERVER['HTTP_USER_AGENT'])) { // Set the client user agent Request::$user_agent = $_SERVER['HTTP_USER_AGENT']; } if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { $requested_with = $_SERVER['HTTP_X_REQUESTED_WITH']; } if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { // Use the forwarded IP address, typically set when the // client is using a proxy server. Request::$client_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { // Use the forwarded IP address, typically set when the // client is using a proxy server. Request::$client_ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (isset($_SERVER['REMOTE_ADDR'])) { // The remote IP address Request::$client_ip = $_SERVER['REMOTE_ADDR']; } if ($method !== 'GET') { // Ensure the raw body is saved for future use $body = file_get_contents('php://input'); } if ($uri === TRUE) { $uri = Request::detect_uri(); } } // Create the instance singleton $request = new Request($uri, $cache); $request->protocol($protocol)->method($method)->referrer($referrer); // Apply the requested with variable isset($requested_with) and $request->requested_with($requested_with); // If there is a body, set it to the model isset($body) and $request->body($body); } else { $request = new Request($uri, $cache); } // Create the initial request if it does not exist if (!Request::$initial) { Request::$initial = $request; $request->query($_GET)->post($_POST); } return $request; }