httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Kobes <ra...@theoryx5.uwinnipeg.ca>
Subject [apreq-2] cookies
Date Tue, 27 Jul 2004 01:23:44 GMT
I'm having a problem with cookies in a simple handler;
this is with the current apreq-2 cvs, current mod_perl-1.99
cvs, and Apache/2.0.50, both on Win32 (perl-5.8.4,
multithreaded) and Linux (perl-5.8.5, non-multithreaded).
All the supplied tests passed on both, save for a couple of
(I think) unrelated minor issues. The handler is :
=======================================================
package Apache::Fail;
use strict;
use warnings;
use Apache::Request;
use Apache::Cookie;
use Apache::RequestRec;
use Apache::RequestUtil;
use Apache::Const -compile => qw(OK);
my $cookie_name = 'cookie_name';

sub handler {
  my $r = shift;
  my $mirror;
  my $req = Apache::Request->new($r);
  my %cookies = Apache::Cookie->fetch($r);
  if (my $c = $cookies{$cookie_name}) {
    $mirror = $c->value;
  }
  else {
    my $host = $req->param('key') || 'default';
    my $cookie = Apache::Cookie->new($r, name => $cookie_name,
                                     value => $host);
    $cookie->bake;
    $mirror = $host;
  }
  $r->content_type('text/html');
  $r->print($mirror);
  Apache::OK;
}
1;
================================================================
with configuration

PerlModule Apache::Fail
<Location /fail>
  SetHandler perl-script
  PerlResponseHandler Apache::Fail
</Location>

If I call this as
   http://localhost/fail?key=whatever
with no cookies present, then the cookie gets created
with the proper value. However, if I then reload
the page, and so try to use the stored cookie, I get
many instances of
  Could not find specified socket in poll list.:
    Skipping bad NAME=VALUE pair: cookie
    Skipping bad NAME=VALUE pair:
    Skipping bad NAME=VALUE pair:
             .....
until I have to kill the server.

The problem seems to be the presence of '_' in the
cookie name - if I use instead a name like
   my $cookie_name = 'cookiename';
then it works. I thought though that it was OK
to have underscores in the cookie name?

-- 
best regards,
randy

Mime
View raw message