i would do it like this to avoid parsing the url at all if we don't need to:

    if ('' != $request->getHeader('Host')) {
        $parsedUrl = parse_url($url);
        if (!isset($parsedUrl['host'])) {
             $request->setHeader('Host', $this->host);
        }
    }