httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Wheeler <da...@kineticode.com>
Subject Re: cookie_jar ignored with requests_redirectable => 1
Date Thu, 29 Jul 2004 21:07:00 GMT
On Jul 28, 2004, at 1:29 AM, Stas Bekman wrote:

> Boris Zentner wrote:
>> Hi,
>> recently I try to use Apache::Test with HTTP::Cookies. But it did not 
>> work as expected. I suppose the way to add a cookie_jar to A::T was 
>> with 'Apache::TestRequest::user_agent'. I read the docs from 
>> Apache::TestRequest::user_agent. Here is the relevant part of it.
>>        And finally, the semantics of the "requests_redirectable"
>>        parameter is different than for "LWP::UserAgent": It
>>        either follows redirects for a request, or it doesn't.
>>        Thus "requests_redirectable" is a boolean value instead of
>>        the array reference that "LWP::UserAgent" expects. To
>> This implies to me that I have the choice to enable or disable 
>> redirects for this useragent with a bool value.
>> Apache::TestRequest::user_agent(
>>   reset => 1,   cookie_jar => $cookie_jar,   requests_redirectable => 
>> 1 );
>> But this way the cookies are ignored. I expected that 
>> HTTP::Cookies->extract_cookies is called after every request. 
>> Therefor I create the cookie_jar from

Oops.

>> package My::Cookies;
>> use base 'HTTP::Cookies';
>> sub extract_cookies {
>>   warn "extract_cookies!!!";
>>   shift->SUPER::extract_cookies(@_);
>> }
>> To get it work, I need to parse the cookie headers myself or 
>> Apache::TestRequest::user_agent(
>>   reset => 1,   cookie_jar => $cookie_jar,   requests_redirectable => 
>> 0 );
>> But here I need to redirect myself or do it with the undocumented 
>> Apache::TestRequest::user_agent(
>>   reset => 1,   cookie_jar => $cookie_jar,   requests_redirectable => 
>> [qw~x y~]
>> );
>> that does anything I want but is undocumented!
>> Here is a part from Apache::TestRequest::user_agent that looks wrong 
>> to me.
>>         my $redir = $args->{requests_redirectable};
>>         if (ref $redir and (@$redir > 1 or $redir->[0] ne 'POST')) {
>>             $RedirectOK = 1;
>>         } else {
>>             $RedirectOK = 0;
>>         }

Does this address the issue?

--- TestRequest.pm.~1.96.~	Thu May  6 12:11:33 2004
+++ TestRequest.pm	Thu Jul 29 14:03:58 2004
@@ -115,7 +115,7 @@

      if (exists $args->{requests_redirectable}) {
          my $redir = $args->{requests_redirectable};
-        if (ref $redir and (@$redir > 1 or $redir->[0] ne 'POST')) {
+        if ((ref $redir and (@$redir > 1 or $redir->[0] ne 'POST')) or 
$redir) {
              $RedirectOK = 1;
          } else {
              $RedirectOK = 0;

I think that I might have changed this code to work this way, and 
overlooked that it could be passed as a simple boolean, even though 
that's the _only_ way it worked before I got my hands on it.

So does passing the array reference actually affect the way the LWP 
user agent object operates? If so, that's cool, but it's undocumented. 
I'm not sure whether it should be documented, though, since if LWP 
isn't installed it certainly won't work with the simple request 
interface that Apache::TestRequest uses in its place.

Regards,

David

Mime
View raw message