PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTTP » HTTP » Bug #7302

Sending port number in request fails entire request on Apache

Details

Submitted2006-04-04 23:07 UTC
Frommarkvds at elegia dot nl
StatusBogus
PackageHTTP
PHP VersionIrrelevant
OSirrelevant
Roadmaps(Not assigned)

Comments

[2006-04-04 23:07 UTC] markvds at elegia dot nl

Description:
------------
HTTP::head() sends the Host header in the form:
Host: www.example.com:80

I noticed a strange bug when requesting a HEAD from an Apache 2.0.51 server. It makes it return a 404 if the port number gets sent along with the hostname.

Actually, I don't know if it's an Apache bug, a bug in the HTTP package or a combination of these. It can be solved in the package, though. The most simple solution is to replace line #190 with:

if ($port == 80) {
$host = $p['host'];
} else {
$host = $p['host'] . ':' . $port;
}
fputs($fp, 'Host: ' . $host . "\r\n");

I think more testing and knowledge is needed to fully understand what goes wrong.

Test script:
---------------
/**
* I don't have any connections with this website; it's just
* the URL where I ran into problems. I don't know the server
* configuration, and of course can't assure that Apache
* 2.0.51 still runs on the server. The last time I checked
* was on April 5, 2006
*/

$result = HTTP::head('http://www.bodarandthebellboys.com/home.htm');
echo $result['response_code'];

Expected result:
----------------
200

Actual result:
--------------
404