> -----Original Message-----
> From: Michael Styer [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 17, 2001 1:05 PM
> To: [EMAIL PROTECTED]
> Subject: help with $r->headers_in->do() method
> 
> 
> Hi there. 
> 
> I've got a question for the mod_perl world about the behavior of the 
> $r->headers_in->do(sub {...some code...}) method.
> 
> I'm writing a proxy handler, and am getting strange results 
> when trying to
> pass headers from the initial request to the proxied request. 
> The problem
> is that the two blocks of code below are supposed to do the same
> thing, and look as though they definitely should do the same 
> thing, but
> don't.
> 
> If anyone has any answers or suggestions, I'd love to hear them.
> 
> Thanks in advance for any advice you might have.
> 
> -mike styer
> 
> 
> <code extract> 
> =========================================================
> 
> ## initial header printout
> 
>     my @headers = $r->headers_in;
>     print STDERR "original headers: \n";
>     while (my ($f, $v) = each %headers) { print STDERR "$f: $v\n"; }
> 
> ## block (1)
> 
>     print STDERR "\nPassing headers: ...\n";
>     $r->headers_in->do(sub {
>         $request->header(@_);
>         #print STDERR "header passed: (@_)\n";
>         });
>     print STDERR "\nPROXY request:\n".$request->as_string."\n";
> 
> ## block (2)
> 
>     print STDERR "\nPassing headers: ...\n";
>     $r->headers_in->do(sub {
>         $request->header(@_);
>         print STDERR "header passed: (@_)\n";
>         });
>     print STDERR "\nPROXY request:\n".$request->as_string."\n";
> 
> <end code extract> 
> =====================================================
> 
> The only difference between those two blocks is the fact that 
> the print
> STDERR "header passed: (@_)\n"; line is commented out in the 
> second block.
> But they produce significantly different output, for no reason that's
> apparent to me.


it probably won't matter, but do() iterates through the table and exits
either when the list is exhausted or the subroutine returns a non-true value

$r->headers_in->do(sub {
  $request->header(@_);
  #print STDERR "header passed: (@_)\n";
  1;
  });

like the Eagle book does and see if that helps.  Otherwise, there might be
something going on internally with Apache where the proxy headers are
stripped.  I don't do proxies, so I'm not that familar with the mechanics of
them...


--Geoff

Reply via email to