/**
  * @test
  */
 public function constructorParsesArgumentsWithSpecialCharactersCorrectly()
 {
     $uriString = 'http://www.typo3.com/path1/?argumentäöü1=' . urlencode('valueåø€œ');
     $uri = new Uri($uriString);
     $check = $uri->getScheme() == 'http' && $uri->getHost() == 'www.typo3.com' && $uri->getPath() == '/path1/' && $uri->getQuery() == 'argumentäöü1=value%C3%A5%C3%B8%E2%82%AC%C5%93' && $uri->getArguments() == array('argumentäöü1' => 'valueåø€œ');
     $this->assertTrue($check, 'The URI with special arguments has not been correctly transformed to an URI object');
 }
 /**
  * Indicates if this request has been received through a secure channel.
  *
  * @return boolean
  * @api
  */
 public function isSecure()
 {
     return $this->uri->getScheme() === 'https';
 }
 /**
  * @param string|Uri $uri
  * @return string
  */
 public function getScheme($uri)
 {
     if ($uri instanceof Uri) {
         return $uri->getScheme();
     }
     if (preg_match(self::PATTERN_SUPPORTED_URIS, $uri, $matches) === 1) {
         return $matches[1];
     }
     return '';
 }
Exemple #4
0
 /**
  * Creates a new Request object from the given data.
  *
  * @param \TYPO3\Flow\Http\Uri $uri The request URI
  * @param string $method Request method, for example "GET"
  * @param array $arguments Arguments to send in the request body
  * @param array $files
  * @param array $server
  * @return \TYPO3\Flow\Http\Request
  * @throws \InvalidArgumentException
  * @api
  */
 public static function create(Uri $uri, $method = 'GET', array $arguments = array(), array $files = array(), array $server = array())
 {
     $get = $uri->getArguments();
     $post = $arguments;
     $isDefaultPort = $uri->getScheme() === 'https' ? $uri->getPort() === 443 : $uri->getPort() === 80;
     $defaultServerEnvironment = array('HTTP_USER_AGENT' => 'Flow/' . FLOW_VERSION_BRANCH . '.x', 'HTTP_HOST' => $uri->getHost() . ($isDefaultPort !== TRUE && $uri->getPort() !== NULL ? ':' . $uri->getPort() : ''), 'SERVER_NAME' => $uri->getHost(), 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => $uri->getPort() ?: 80, 'REMOTE_ADDR' => '127.0.0.1', 'SCRIPT_FILENAME' => FLOW_PATH_WEB . 'index.php', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php');
     if ($uri->getScheme() === 'https') {
         $defaultServerEnvironment['HTTPS'] = 'on';
         $defaultServerEnvironment['SERVER_PORT'] = $uri->getPort() ?: 443;
     }
     if (in_array($method, array('POST', 'PUT', 'DELETE'))) {
         $defaultServerEnvironment['HTTP_CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
     }
     $query = $uri->getQuery();
     $fragment = $uri->getFragment();
     $overrideValues = array('REQUEST_URI' => $uri->getPath() . ($query !== '' ? '?' . $query : '') . ($fragment !== '' ? '#' . $fragment : ''), 'REQUEST_METHOD' => $method, 'QUERY_STRING' => $query);
     $server = array_replace($defaultServerEnvironment, $server, $overrideValues);
     return new static($get, $post, $files, $server);
 }