Re: Unable to set custom header

Ashish Mukherjee <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CACgMzfy77pFTeGKvYDVQXxuqEVV=BLTeGojik8LKxJ3b=Q9jOw@mail.gmail.com>
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?

On Tue, Oct 6, 2015 at 2:53 PM, Jie Gao <[email protected]> wrote:

> Please think of our environment and only print this e-mail if necessary.
>
> * Ashish Mukherjee <[email protected]> wrote:
>
> > Date: Tue, 6 Oct 2015 14:36:32 +0530
> > From: Ashish Mukherjee <[email protected]>
> > To: [email protected]
> > CC: [email protected]
> > 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
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.