FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=19156&edit=1

ID: 19156
Updated by: borz_off@cs.msu.su
Reported By: jo at feuersee dot de
Summary: isRedirected() reports FALSE even when redirected if
HTTP HEAD used.
-Status: Open
+Status: Bogus
Type: Bug
Package: HTTP_Request2
Operating System: Linux
Package Version: 2.0.0
PHP Version: 5.3.8
Roadmap Versions:
New Comment:

-Status: Open
+Status: Bogus
The note on the manual page dealing with "HTTP Redirects" specifically
states:
HTTP_Request2::send will return only the final response, if you
are interested in the intermediate ones you should use Observers.

http://pear.php.net/manual/en/package.http.http-request2.request.php

Basically you are getting the response for a second request, done after
following a redirect. And that response is not a redirect itself.


Previous Comments:
------------------------------------------------------------------------

[2011-12-22 16:00:17] panamajo

Description:
------------
When using METHOD_HEAD the method isRedirect() always reports FALSE even
if a redirect was followed.

Test script:
---------------
<?php
/**
* test if PEAR HTTP_Request2 handles redirects correctly with HTTP
HEAD
*/
header('Content-Type: text/plain; charset=UTF-8');

require_once 'PEAR/HTTP/Request2.php';

// this URL will redirect to a nearby mirror
$url = 'http://www.php.net/search.php?pattern=date&show=quickref';
$req = new HTTP_Request2($url, HTTP_REQUEST2::METHOD_HEAD,
array('follow_redirects' => TRUE));
$resp = $req->send();

printf("Requested URL = %s\n", $url);
printf("isRedirect() = %d\n", $resp->isRedirect());
printf("getEffectiveUrl() = %s\n", $resp->getEffectiveUrl());



Expected result:
----------------
Requested URL =
http://www.php.net/search.php?pattern=date&show=quickref
isRedirect() = 1
getEffectiveUrl() = http://de3.php.net/manual/de/function.date.php


Actual result:
--------------
Requested URL =
http://www.php.net/search.php?pattern=date&show=quickref
isRedirect() = 0
getEffectiveUrl() = http://de3.php.net/manual/de/function.date.php

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJan 4, '12 at 8:54p
activeJan 4, '12 at 8:54p
posts1
users1
websitepear.php.net

1 user in discussion

Borz_off: 1 post

People

Translate

site design / logo © 2022 Grokbase