public function asString()
    {
        $path   = $this->path;
        $scheme = $identity = $host = $port = $encoded = $fragment = '';
        if ($this->username && $this->password) {
            $identity = $this->username . ':' . $this->password . '@';
        }
        if ($this->getHost()) {
            $scheme = $this->getScheme() ? $this->getScheme() : 'http';
            $scheme .= '://';
            $host = $this->getHost();
        } elseif ($this->getScheme() === 'file') {
            // Safest way; otherwise, file URLs on Windows have an extra
            // leading slash. It might be possible to convert file://
            // URIs to local file paths, but that requires more research.
            $scheme = 'file://';
        }
        if ($this->getPort() && $this->getPort() != 80) {
            $port = ':' . $this->getPort();
        }

        if (substr($this->path, 0, 1) == '/') {
            $path = $this->normalisePath($this->path);
        }
        $encoded  = $this->getEncodedRequest();
        $fragment = $this->getFragment() ? '#' . $this->getFragment() : '';
        $coords   = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();

        return "$scheme$identity$host$port$path$encoded$fragment$coords";
    }