note 101331 modified in function.parse-url by danbrown

From: Date: Fri, 10 Dec 2010 17:11:05 +0000
Subject: note 101331 modified in function.parse-url by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174775@lists.php.net to get a copy of this message
It seems the host-part strips off the last [:port] off the end of the hostname When something is wrong in the actual request, this proves to be the wrong way to do things. It would be better to not strip off the [:port], but to keep the string *before* the first [:port] as the hostname. Problem with (maybe malformed) provided HTTP_HOST hostname:443:443 that resolved in 'host' => 'hostname:443' Which gave me problems. Solution would be to enforce this yourself, explicitly: <?php $p = parse_url( $url ); $host = explode(':', $p['host']); $hostname = $host[0]; ?> --was-- It seems the host-part strips off the last [:port] off the end of the hostname When something is wrong in the actual request, this proves to be the wrong way to do things. It would be better to not strip off the [:port], but to keep the string *before* the first [:port] as the hostname. Problem with (maybe malformed) provided HTTP_HOST hostname:443:443 that resolved in 'host' => 'hostname:443' Which gave me problems. Solution would be to enforce this yourself, explicitly: $p = parse_url( $url ); $host = explode(':', $p['host']); $hostname = $host[0]; http://php.net/manual/en/function.parse-url.php

« previous php.notes (#174775) next »