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 21:45:43 UTC

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(242): [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(235): [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(227): [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(227): [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(227): [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