You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jason Bodnar <jb...@tivoli.com> on 2000/02/18 23:10:18 UTC

RE: Bug with $res->scan(sub {$r->header_out(@_);}); from Eagle

Unfortunately, neither of those work. I think they all end up calling the same
Apache function (table_set) which is blowing away the previous values.

On 18-Feb-00 Geoffrey Young wrote:
> 
> I wonder if you will get better results using 
> $r->headers_out(@_) or $r->headers_out->add(@_)
> that access Apache::Table instead?
> 
> I don't really know the underlying code, but it seems $r->header_out() is
> behaving as documented - see p444
> "If passed a key/value pair, header_out() stably __changes__ the value of
> the corresponding header field."
> 
> Interesting problem, though... hmmm...
> 
> --Geoff
> 
>> -----Original Message-----
>> From: Jason Bodnar [mailto:jbodnar@tivoli.com]
>> Sent: Friday, February 18, 2000 3:46 PM
>> To: mod_perl list
>> Subject: Bug with $res->scan(sub {$r->header_out(@_);}); from 
>> Eagle book
>> 
>> 
>> I think I found another bug with a line of code from the 
>> image blocker/proxy
>> example in the Eagle book.
>> 
>> The line:
>> 
>>  $res->scan(sub {$r->header_out(@_);});
>> 
>> Is supposed to copy all the headers returned in a LWP request 
>> into the Apache
>> request object.
>> 
>> Here are the headers coming back from an LWP request:
>> 
>> [Fri Feb 18 13:49:47 2000] [debug]
>> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(24
>> 2): [client
>> 146.84.34.20] /showcase/status/validate.cfm: Date: Fri, 18 
>> Feb 2000 19:49:21 GMT
>> Server: Microsoft-IIS/4.0
>> Content-Type: text/html
>> Client-Date: Fri, 18 Feb 2000 19:49:47 GMT
>> Client-Peer: 146.84.104.69:80
>> Set-Cookie: USER_LOGON=jbodnar; expires=Sat, 19-Feb-2000 
>> 13:49:21 GMT; path=/; 
>> Set-Cookie: USER_CODE=67; expires=Sat, 19-Feb-2000 13:49:21 
>> GMT; path=/; 
>> Set-Cookie: USER_NAME=Jason+Bodnar; expires=Sat, 19-Feb-2000 
>> 13:49:21 GMT;
>> path=/; 
>> Title: Virtual TaskMaster: Logon Validation
>> 
>> Notice that three cookies are set.
>> 
>> Now here are the headers in the Apache request ($r) on the 
>> way out to the
>> browser:
>> 
>> [Fri Feb 18 14:22:16 2000] [debug]
>> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(23
>> 5): [client
>> 146.84.34.20] /showcase/status/validate.cfm: Client-Peer: 
>> 146.84.104.69:80
>> Title: Virtual TaskMaster: Logon Validation
>> Client-Date: Fri, 18 Feb 2000 20:22:16 GMT
>> Content-Type: text/html
>> Set-Cookie: USER_NAME=Jason+Bodnar; expires=Sat, 19-Feb-2000 
>> 14:21:49 GMT;
>> path=/; 
>> Date: Fri, 18 Feb 2000 20:21:49 GMT
>> Server: Microsoft-IIS/4.0
>> 
>> Now, there's only one cookie being sent to the browser.
>> 
>> Let's dig a little deeper. If we take the line above that is 
>> setting the
>> headers for $r on the way out and change it to:
>> 
>> $res->scan(sub {$r->log->debug("RES HEADER: @_"); 
>> $r->header_out(@_);});
>> 
>> We get the following:
>> 
>> [Fri Feb 18 14:26:29 2000] [debug]
>> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(22
>> 7): [client
>> 146.84.34.20] RES HEADER: Set-Cookie USER_LOGON=jbodnar; expires=Sat,
>> 19-Feb-2000 14:26:02 GMT; path=/; 
>> [Fri Feb 18 14:26:29 2000] [debug]
>> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(22
>> 7): [client
>> 146.84.34.20] RES HEADER: Set-Cookie USER_CODE=67; 
>> expires=Sat, 19-Feb-2000
>> 14:26:02 GMT; path=/; 
>> [Fri Feb 18 14:26:29 2000] [debug]
>> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(22
>> 7): [client
>> 146.84.34.20] RES HEADER: Set-Cookie USER_NAME=Jason+Bodnar; 
>> expires=Sat,
>> 19-Feb-2000 14:26:02 GMT; path=/; 
>> 
>> So it appears that the bug is actually in $r->header_out. It 
>> does not seem to
>> handle multiple headers of the same name correctly as the 
>> last one (USER_NAME)
>> is the only one actually going out to the browser. Digging 
>> around in the src I
>> think this may actually be an Apache bug? I sure hope not. 
>> I'll dig some more
>> and see if I can find a fix. If not, maybe there's a workaround.
>> 
>> ---
>> Jason Bodnar + jbodnar@tivoli.com + Tivoli Systems
>> 
>> In Jail Rock house Rock, he was everything Rockabilly's about.
>> No, I mean he is Rockabilly. Mean, Surly, Nasty, Brute.
>> I mean in that movie he couldn't give a ---- about nothin'.
>> Just rockin' and rollin', livin' fast, dying young, leavin' a 
>> good lookin'
>> corpse.
>> 
>> --Clarence Worley, True Romance
>> 

---
Jason Bodnar + jbodnar@tivoli.com + Tivoli Systems

I strive for greatness but will settle for mediocrity. -- Jason Bodnar


Re: Bug with $res->scan(sub {$r->header_out(@_);}); from Eagle

Posted by Jason Bodnar <jb...@tivoli.com>.
This is very odd. If I change my code to:

$res->scan(sub {$r->headers_out->add(@_);});

and then do:

$r->log->debug($r->uri, ": ", Dumper(scalar $r->headers_out));

I get the following:

[Mon Feb 21 11:48:46 2000] [debug]
/opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(241): [client
146.84.34.20] /showcase/status/validate.cfm: $VAR1 = bless( {
                 'Date' => 'Mon, 21 Feb 2000 17:48:14 GMT',
                 'Server' => 'Microsoft-IIS/4.0',
                 'Content-Type' => 'text/html',
                 'Client-Date' => 'Mon, 21 Feb 2000 17:48:46 GMT',
                 'Client-Peer' => '146.84.104.69:80',
                 'Set-Cookie' => 'USER_LOGON=jbodnar; expires=Tue, 22-Feb-2000
11:48:14 GMT; path=/; ',
                 'Set-Cookie' => 'USER_LOGON=jbodnar; expires=Tue, 22-Feb-2000
11:48:14 GMT; path=/; ',
                 'Set-Cookie' => 'USER_LOGON=jbodnar; expires=Tue, 22-Feb-2000
11:48:14 GMT; path=/; ',
                 'Title' => 'Virtual TaskMaster: Logon Validation'
               }, 'Apache::Table' );

According to this output, the same cookie is getting set every time. But, if I
go to the next page and look at the headers my browser is sending:

[Mon Feb 21 11:50:42 2000] [debug]
/opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(211): [client
146.84.34.20] /showcase/status/session/task_results.cfm: Accept: image/gif,
image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*
Accept-Charset: iso-8859-1,*,utf-8
Accept-Encoding: gzip
Accept-Language: en
Host: dw3.tivoli.com
Referer: http://dw3.tivoli.com/showcase/status/validate.cfm
User-Agent: Mozilla/4.7 [en] (X11; U; Linux 2.2.13-7mdk i686)
Cookie: USER_NAME=Jason+Bodnar; USER_LOGON=jbodnar; USER_CODE=67

It's sending three different cookies which is what it should be sending.

So how are those cookies getting to the browser when it appears Apache was
going to three identical cookies?

On 18-Feb-00 Aaron Ross wrote:
> hi Jason!
> 
>  $r->headers_out->add works fine for me.
> 
> aaron
> 
>> Unfortunately, neither of those work. I think they all end up calling the
>> same
>> Apache function (table_set) which is blowing away the previous values.
>> 
>> On 18-Feb-00 Geoffrey Young wrote:
>> > 
>> > I wonder if you will get better results using 
>> > $r->headers_out(@_) or $r->headers_out->add(@_)
>> > that access Apache::Table instead?
>> > 
>> > I don't really know the underlying code, but it seems $r->header_out() is
>> > behaving as documented - see p444
>> > "If passed a key/value pair, header_out() stably __changes__ the value of
>> > the corresponding header field."
>> > 
>> > Interesting problem, though... hmmm...
>> > 
>> > --Geoff
>> > 
>> >> -----Original Message-----
>> >> From: Jason Bodnar [mailto:jbodnar@tivoli.com]
>> >> Sent: Friday, February 18, 2000 3:46 PM
>> >> To: mod_perl list
>> >> Subject: Bug with $res->scan(sub {$r->header_out(@_);}); from 
>> >> Eagle book
>> >> 
>> >> 
>> >> I think I found another bug with a line of code from the 
>> >> image blocker/proxy
>> >> example in the Eagle book.
>> >> 
>> >> The line:
>> >> 
>> >>  $res->scan(sub {$r->header_out(@_);});
>> >> 
>> >> Is supposed to copy all the headers returned in a LWP request 
>> >> into the Apache
>> >> request object.
>> >> 
>> >> Here are the headers coming back from an LWP request:
>> >> 
>> >> [Fri Feb 18 13:49:47 2000] [debug]
>> >> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(24
>> >> 2): [client
>> >> 146.84.34.20] /showcase/status/validate.cfm: Date: Fri, 18 
>> >> Feb 2000 19:49:21 GMT
>> >> Server: Microsoft-IIS/4.0
>> >> Content-Type: text/html
>> >> Client-Date: Fri, 18 Feb 2000 19:49:47 GMT
>> >> Client-Peer: 146.84.104.69:80
>> >> Set-Cookie: USER_LOGON=jbodnar; expires=Sat, 19-Feb-2000 
>> >> 13:49:21 GMT; path=/; 
>> >> Set-Cookie: USER_CODE=67; expires=Sat, 19-Feb-2000 13:49:21 
>> >> GMT; path=/; 
>> >> Set-Cookie: USER_NAME=Jason+Bodnar; expires=Sat, 19-Feb-2000 
>> >> 13:49:21 GMT;
>> >> path=/; 
>> >> Title: Virtual TaskMaster: Logon Validation
>> >> 
>> >> Notice that three cookies are set.
>> >> 
>> >> Now here are the headers in the Apache request ($r) on the 
>> >> way out to the
>> >> browser:
>> >> 
>> >> [Fri Feb 18 14:22:16 2000] [debug]
>> >> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(23
>> >> 5): [client
>> >> 146.84.34.20] /showcase/status/validate.cfm: Client-Peer: 
>> >> 146.84.104.69:80
>> >> Title: Virtual TaskMaster: Logon Validation
>> >> Client-Date: Fri, 18 Feb 2000 20:22:16 GMT
>> >> Content-Type: text/html
>> >> Set-Cookie: USER_NAME=Jason+Bodnar; expires=Sat, 19-Feb-2000 
>> >> 14:21:49 GMT;
>> >> path=/; 
>> >> Date: Fri, 18 Feb 2000 20:21:49 GMT
>> >> Server: Microsoft-IIS/4.0
>> >> 
>> >> Now, there's only one cookie being sent to the browser.
>> >> 
>> >> Let's dig a little deeper. If we take the line above that is 
>> >> setting the
>> >> headers for $r on the way out and change it to:
>> >> 
>> >> $res->scan(sub {$r->log->debug("RES HEADER: @_"); 
>> >> $r->header_out(@_);});
>> >> 
>> >> We get the following:
>> >> 
>> >> [Fri Feb 18 14:26:29 2000] [debug]
>> >> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(22
>> >> 7): [client
>> >> 146.84.34.20] RES HEADER: Set-Cookie USER_LOGON=jbodnar; expires=Sat,
>> >> 19-Feb-2000 14:26:02 GMT; path=/; 
>> >> [Fri Feb 18 14:26:29 2000] [debug]
>> >> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(22
>> >> 7): [client
>> >> 146.84.34.20] RES HEADER: Set-Cookie USER_CODE=67; 
>> >> expires=Sat, 19-Feb-2000
>> >> 14:26:02 GMT; path=/; 
>> >> [Fri Feb 18 14:26:29 2000] [debug]
>> >> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(22
>> >> 7): [client
>> >> 146.84.34.20] RES HEADER: Set-Cookie USER_NAME=Jason+Bodnar; 
>> >> expires=Sat,
>> >> 19-Feb-2000 14:26:02 GMT; path=/; 
>> >> 
>> >> So it appears that the bug is actually in $r->header_out. It 
>> >> does not seem to
>> >> handle multiple headers of the same name correctly as the 
>> >> last one (USER_NAME)
>> >> is the only one actually going out to the browser. Digging 
>> >> around in the src I
>> >> think this may actually be an Apache bug? I sure hope not. 
>> >> I'll dig some more
>> >> and see if I can find a fix. If not, maybe there's a workaround.
>> >> 
>> >> ---
>> >> Jason Bodnar + jbodnar@tivoli.com + Tivoli Systems
>> >> 
>> >> In Jail Rock house Rock, he was everything Rockabilly's about.
>> >> No, I mean he is Rockabilly. Mean, Surly, Nasty, Brute.
>> >> I mean in that movie he couldn't give a ---- about nothin'.
>> >> Just rockin' and rollin', livin' fast, dying young, leavin' a 
>> >> good lookin'
>> >> corpse.
>> >> 
>> >> --Clarence Worley, True Romance
>> >> 
>> 
>> ---
>> Jason Bodnar + jbodnar@tivoli.com + Tivoli Systems
>> 
>> I strive for greatness but will settle for mediocrity. -- Jason Bodnar

---
Jason Bodnar + jbodnar@tivoli.com + Tivoli Systems

I strive for greatness but will settle for mediocrity. -- Jason Bodnar


Re: Bug with $res->scan(sub {$r->header_out(@_);}); from Eagle

Posted by Aaron Ross <ro...@mathforum.com>.
hi Jason!

 $r->headers_out->add works fine for me.

aaron

> Unfortunately, neither of those work. I think they all end up calling the same
> Apache function (table_set) which is blowing away the previous values.
> 
> On 18-Feb-00 Geoffrey Young wrote:
> > 
> > I wonder if you will get better results using 
> > $r->headers_out(@_) or $r->headers_out->add(@_)
> > that access Apache::Table instead?
> > 
> > I don't really know the underlying code, but it seems $r->header_out() is
> > behaving as documented - see p444
> > "If passed a key/value pair, header_out() stably __changes__ the value of
> > the corresponding header field."
> > 
> > Interesting problem, though... hmmm...
> > 
> > --Geoff
> > 
> >> -----Original Message-----
> >> From: Jason Bodnar [mailto:jbodnar@tivoli.com]
> >> Sent: Friday, February 18, 2000 3:46 PM
> >> To: mod_perl list
> >> Subject: Bug with $res->scan(sub {$r->header_out(@_);}); from 
> >> Eagle book
> >> 
> >> 
> >> I think I found another bug with a line of code from the 
> >> image blocker/proxy
> >> example in the Eagle book.
> >> 
> >> The line:
> >> 
> >>  $res->scan(sub {$r->header_out(@_);});
> >> 
> >> Is supposed to copy all the headers returned in a LWP request 
> >> into the Apache
> >> request object.
> >> 
> >> Here are the headers coming back from an LWP request:
> >> 
> >> [Fri Feb 18 13:49:47 2000] [debug]
> >> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(24
> >> 2): [client
> >> 146.84.34.20] /showcase/status/validate.cfm: Date: Fri, 18 
> >> Feb 2000 19:49:21 GMT
> >> Server: Microsoft-IIS/4.0
> >> Content-Type: text/html
> >> Client-Date: Fri, 18 Feb 2000 19:49:47 GMT
> >> Client-Peer: 146.84.104.69:80
> >> Set-Cookie: USER_LOGON=jbodnar; expires=Sat, 19-Feb-2000 
> >> 13:49:21 GMT; path=/; 
> >> Set-Cookie: USER_CODE=67; expires=Sat, 19-Feb-2000 13:49:21 
> >> GMT; path=/; 
> >> Set-Cookie: USER_NAME=Jason+Bodnar; expires=Sat, 19-Feb-2000 
> >> 13:49:21 GMT;
> >> path=/; 
> >> Title: Virtual TaskMaster: Logon Validation
> >> 
> >> Notice that three cookies are set.
> >> 
> >> Now here are the headers in the Apache request ($r) on the 
> >> way out to the
> >> browser:
> >> 
> >> [Fri Feb 18 14:22:16 2000] [debug]
> >> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(23
> >> 5): [client
> >> 146.84.34.20] /showcase/status/validate.cfm: Client-Peer: 
> >> 146.84.104.69:80
> >> Title: Virtual TaskMaster: Logon Validation
> >> Client-Date: Fri, 18 Feb 2000 20:22:16 GMT
> >> Content-Type: text/html
> >> Set-Cookie: USER_NAME=Jason+Bodnar; expires=Sat, 19-Feb-2000 
> >> 14:21:49 GMT;
> >> path=/; 
> >> Date: Fri, 18 Feb 2000 20:21:49 GMT
> >> Server: Microsoft-IIS/4.0
> >> 
> >> Now, there's only one cookie being sent to the browser.
> >> 
> >> Let's dig a little deeper. If we take the line above that is 
> >> setting the
> >> headers for $r on the way out and change it to:
> >> 
> >> $res->scan(sub {$r->log->debug("RES HEADER: @_"); 
> >> $r->header_out(@_);});
> >> 
> >> We get the following:
> >> 
> >> [Fri Feb 18 14:26:29 2000] [debug]
> >> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(22
> >> 7): [client
> >> 146.84.34.20] RES HEADER: Set-Cookie USER_LOGON=jbodnar; expires=Sat,
> >> 19-Feb-2000 14:26:02 GMT; path=/; 
> >> [Fri Feb 18 14:26:29 2000] [debug]
> >> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(22
> >> 7): [client
> >> 146.84.34.20] RES HEADER: Set-Cookie USER_CODE=67; 
> >> expires=Sat, 19-Feb-2000
> >> 14:26:02 GMT; path=/; 
> >> [Fri Feb 18 14:26:29 2000] [debug]
> >> /opt/apache/dw3.tivoli.com/80/lib/perl/Apache/ProxyStuff.pm(22
> >> 7): [client
> >> 146.84.34.20] RES HEADER: Set-Cookie USER_NAME=Jason+Bodnar; 
> >> expires=Sat,
> >> 19-Feb-2000 14:26:02 GMT; path=/; 
> >> 
> >> So it appears that the bug is actually in $r->header_out. It 
> >> does not seem to
> >> handle multiple headers of the same name correctly as the 
> >> last one (USER_NAME)
> >> is the only one actually going out to the browser. Digging 
> >> around in the src I
> >> think this may actually be an Apache bug? I sure hope not. 
> >> I'll dig some more
> >> and see if I can find a fix. If not, maybe there's a workaround.
> >> 
> >> ---
> >> Jason Bodnar + jbodnar@tivoli.com + Tivoli Systems
> >> 
> >> In Jail Rock house Rock, he was everything Rockabilly's about.
> >> No, I mean he is Rockabilly. Mean, Surly, Nasty, Brute.
> >> I mean in that movie he couldn't give a ---- about nothin'.
> >> Just rockin' and rollin', livin' fast, dying young, leavin' a 
> >> good lookin'
> >> corpse.
> >> 
> >> --Clarence Worley, True Romance
> >> 
> 
> ---
> Jason Bodnar + jbodnar@tivoli.com + Tivoli Systems
> 
> I strive for greatness but will settle for mediocrity. -- Jason Bodnar