Re: HTTP_Request not following redirects
| From: | diro at nixsys dot bz | Date: | Sun, 03 Dec 2006 19:55:44 +0000 |
| Subject: | Re: HTTP_Request not following redirects | ||
| References: | 1 2 3 4 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25969@lists.php.net to get a copy of this message | ||
On Sun, Dec 03, 2006 at 10:32:13PM +0300, Alexey Borzov wrote:
> Hi,
>
> diro@nixsys.bz wrote:
> >>>Any ideas? Need more info?
> >>Redirect support in HTTP_Request is switched off by default for a reason.
> >>That reason being that it wasn't touched for quite a bit of time and is
> >>deprecated.
> >
> >What was it replaced by?
>
> HTTP_Client. Redirect support was added to HTTP_Request by its author as an
> afterthought and doesn't quite fit into the architecture.
Okay, thanks. I'm new to PEAR and have only played with what's in pkgsrc-2006Q3.
I'll import HTTP_Client into pkgsrc-wip today and request a review after the
testing is done.
> >I got the results i wanted by calling new HTTP_Request with an empty URL
> >and
> >allowRedirects and then using setURL to supply the query string.
>
> That's hard to believe, since the constructor calls setUrl() method itself.
I know! I looked through the code and couldn't understand why it didn't work.
<?php
include ('HTTP/Request.php');
$req = &new HTTP_Request('', array('allowRedirects'=>true));
$req->setUrl('http://$TEST_SITE/test.cgi?var1=arg1&var2=arg2&var3=arg3');
$req->sendRequest();
$response1 = $req->getResponseBody();
echo $response1;
?>
Believe! :-)