PEAR is archived and read-only

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

Home » HTTP » HTTP » Bug #2332

[PATCH] redirect() doesn't comply with RFC2616

Details

Submitted2004-09-14 20:55 UTC
Fromieure at php dot net
Assignedmike
StatusClosed
PackageHTTP
PHP Version4.3.8
OSLinux
Roadmaps(Not assigned)

Comments

[2004-09-14 20:55 UTC] ieure at php dot net

Description:
------------
According to RFC2616:

"Unless the request method was HEAD, the entity of the
response SHOULD contain a short hypertext note with a
hyperlink to the new URI(s)."

This is not the case with PEAR::HTTP. Certain user-agents
(such as WAP browsers) do not follow redirects unless there
is content returned by the GET request.

Patch follows:
--- HTTP.php.orig 2004-09-14 13:49:10.000000000 -0700
+++ HTTP.php 2004-09-14 13:52:18.000000000 -0700
@@ -226,6 +226,9 @@
header('Location: '. HTTP::absoluteURI($url));

if ($exit) {
+ if ($_SERVER['REQUEST_METHOD'] != 'HEAD') {
+ echo "Redirecting to: <a
href="{$url}">{$url}</a>";
+ }
exit;
}
return true;

Reproduce code:
---------------
require_once 'HTTP.php';
HTTP::redirect("http://www.example.com");

Expected result:
----------------
The "Location" HTTP header should be set, and a hypertext
note should be sent in the body of the response, in
compliance with RFC2616.

Actual result:
--------------
No body content is sent for GET requests.