Ejemplo n.º 1
0
 public function __construct(Configuration $config, RequestInterface $request)
 {
     $this->_uriComponents = array();
     $this->_config = $config;
     $requestHeaders = $request->getHeaders();
     $this->scheme($request->isSecure() ? 'https' : 'http');
     if (isset($requestHeaders['host'])) {
         $this->host($requestHeaders['host']);
     }
     // set the port number using the one from the Request, or the default
     // for the request scheme
     if ($request->getPort()) {
         $this->port($request->getPort());
     } else {
         if ('http' == $this->_uriComponents['scheme']) {
             $this->port(80);
         } else {
             if ('ftp' == $this->_uriComponents['scheme']) {
                 $this->port(21);
             }
         }
     }
     $this->_queryParams = $request->getQueryParams();
     $requestUri = $request->getRequestUri();
     if (($hashOffset = strpos('#', $requestUri)) !== FALSE) {
         $this->replacePath(strstr($requestUri, '#', true));
         $this->fragment(substr(strstr($requestUri, '#'), 1));
     } else {
         $this->replacePath($requestUri);
     }
 }