Mailing List Archive

RE: Bug with $res->scan(sub {$r->header_out(@_);}); from Eagle b ook
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
>