Re: [Patch] HTTP::absoluteURI() port redundancy
| From: | Philippe Jausions | Date: | Fri, 10 Sep 2004 02:12:03 +0000 |
| Subject: | Re: [Patch] HTTP::absoluteURI() port redundancy | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-33326@lists.php.net to get a copy of this message | ||
Turadg,
When I originally submitted my patch for HTTP package, I did make sure such thing didn't happen. I guess it didn't make it through.
Back then I submitted this patch:
http://www.11abacus.com/cvs/pear/HTTP.diff
I introduced a private method to check against common default port numbers. You patch only takes care of http and https. What about ftp, telnet and other URL the user could be redirected to...?
Agreed with you this is a bug. The port number shouldn't be appended when the port matches the standard one for the protocol... Please open a bug report under the package.
-Philippe
Turadg Aleahmad wrote:
This is a simple patch to eliminate the redundant port field of absolute URIs when it's already implied by the protocol. If given a relative URL like /myfile it will change it to http://$SERVER_NAME:$SERVER_PORT even if the port is 80. I use HTTP::redirect() on my site, which makes use of absoluteURI(), and Safari users have reported that they see the :80 in their URLs. This isn't merely aesthetic; it confuses many users.
The patch below checks if the port is already implied by the protocol and omits it if so.
diff HTTP.php-in-cvs HTTP.php-that-I-edited
285a286,288
if ($protocol == 'http' && $port == 80) unset($port);
if ($protocol == 'https' && $port == 443) unset($port);
Note, this sounds similar but is different from Bug #1040.
-Turadg