[prev in list] [next in list] [prev in thread] [next in thread]
List: apache-modperl
Subject: Re: Unable to set custom header
From: Issac Goldstand <margol () beamartyr ! net>
Date: 2015-10-06 10:49:18
Message-ID: 5613A72E.4010203 () beamartyr ! net
[Download RAW message or body]
$r->headers_out is what would go to the client. You probably want to
add your headers to $r->headers_in to get it passed to the upstream server.
Issac
On 10/6/2015 1:11 PM, Ashish Mukherjee wrote:
> Error log does not show anything. It's almost as if that piece of code
> never existed!
>
> The request is already being created by mod_proxy. I am just trying to
> append some request headers.
>
> On Tue, Oct 6, 2015 at 3:25 PM, Jie Gao <J.Gao@sydney.edu.au
> <mailto:J.Gao@sydney.edu.au>> wrote:
>
> * Ashish Mukherjee <ashish.mukherjee@gmail.com
> <mailto:ashish.mukherjee@gmail.com>> wrote:
>
> > Date: Tue, 6 Oct 2015 15:06:21 +0530
> > From: Ashish Mukherjee <ashish.mukherjee@gmail.com
> <mailto:ashish.mukherjee@gmail.com>>
> > To: Jie Gao <J.Gao@sydney.edu.au <mailto:J.Gao@sydney.edu.au>>
> > CC: modperl@perl.apache.org <mailto:modperl@perl.apache.org>,
> sourabh.d.v@smartinsight.jp <mailto:sourabh.d.v@smartinsight.jp>
> > Subject: Re: Unable to set custom header
> >
> > Yes, I used that code just to try with foo => bar first, before doing
> > anything more complex. err_headers_out() does not work either. Should I set
> > this handler in some other phase?
>
> Your code does not seem to complete the response. Try to do it
> properly, by setting the content type and print a body, etc.
>
> Also anything in the error log that would suggest why it did not work?
>
>
> -Jie
>
>
> > On Tue, Oct 6, 2015 at 2:53 PM, Jie Gao <J.Gao@sydney.edu.au
> <mailto:J.Gao@sydney.edu.au>> wrote:
> >
> > > Please think of our environment and only print this e-mail if
> necessary.
> > >
> > > * Ashish Mukherjee <ashish.mukherjee@gmail.com
> <mailto:ashish.mukherjee@gmail.com>> wrote:
> > >
> > > > Date: Tue, 6 Oct 2015 14:36:32 +0530
> > > > From: Ashish Mukherjee <ashish.mukherjee@gmail.com
> <mailto:ashish.mukherjee@gmail.com>>
> > > > To: modperl@perl.apache.org <mailto:modperl@perl.apache.org>
> > > > CC: sourabh.d.v@smartinsight.jp
> <mailto:sourabh.d.v@smartinsight.jp>
> > > > Subject: Unable to set custom header
> > > >
> > > > Hello,
> > > >
> > > > I am trying to set a custom header through a mod_perl handler.
> > > >
> > > > My perl handler code is:
> > > >
> > > > sub handler {
> > > > my $r = shift;
> > > >
> > > > $r->headers_out->add("foo" => "bar");
> > > > $r->log->error($r->connection->remote_ip()." is client IP");
> > > >
> > > > return Apache2::Const::OK;
> > > > }
> > > >
> > > > The handler gets called as I am able to see the log message,
> but the
> > > header
> > > > is not emitted.
> > >
> > > Is this the actual code you used? The response headers set by
> > > "headers_out" get cleared if there is an error, nor do they
> persist across
> > > internal redirects.
> > >
> > > You might want to try err_headers_out instead, depending on the
> > > circumstances.
> > >
> > > Regards,
> > >
> > >
> > >
> > > Jie
> > >
> > >
> > > > My Apache configuration is -
> > > >
> > > > ProxyRequests On
> > > > ProxyVia On
> > > > ProxyRemote * http://localhost:3128
> > > >
> > > > SetHandler modperl
> > > > PerlPostReadRequestHandler +Foo::Proxy
> > > >
> > > > <Location />
> > > > ProxyPass http://www.something.com/
> > > > ProxyPassReverse http://www.something.com/
> > > > </Location>
> > > >
> > > > When I do the same through mod_header like this it works -
> > > >
> > > > RequestHeader set foo bar
> > > >
> > > > I want foo: bar to go as a header in the HTTP request to my
> proxy on port
> > > > 3128.
> > > >
> > > > Can anyone advise why my perl handler doesn't work when it
> should be
> > > doing
> > > > the same thing as mod_headers?
> > > >
> > > > Regards,
> > > > Ashish
> > >
>
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic