/** * Constructor. * * @access public * @param HTTPConnect $connection * @apram string $method * @param string $uri * @param string $version * @param HTTPHeaders $headers * @param string $remote_ip * @param string $protocol * @param string $host * @param array $files * @return void */ public function __construct(HTTPConnection $connection, $method, $uri, $version = 'HTTP/1.0', $headers = null, $remote_ip = null) { $this->method = $method; if (strpos($uri, '?') !== false) { $url = mb_substr($uri, 0, mb_strpos($uri, '?', 0, 'UTF-8'), 'UTF-8'); } else { $url = $uri; } $this->set_uri($url); $this->version = $version; $this->headers = $headers; $this->remote_ip = reset(explode(':', $remote_ip)); $this->connection = $connection; $this->start_time = time(); // Pull some data out of the headers. if (!empty($headers['Host'])) { $host = $headers['Host']; } else { $host = '127.0.0.1'; } $this->host = $host; // Break up the URI into different parts. $parts = parse_url($uri); $this->path = $parts['path']; if (!empty($parts['query'])) { $this->query = $parts['query']; parse_str($parts['query'], $args); if (!empty($args)) { foreach ($args as $name => $values) { if (!empty($values)) { $this->get[$name] = $values; } } } } // Pull out the cookies if there are any. if ($this->headers->has('Cookie')) { $cookies = explode(';', $this->headers->get('Cookie')); foreach ($cookies as $cookie) { list($name, $value) = explode('=', trim($cookie), 2); $this->cookie[$name] = $value; } } }