On 24 Dec 2004 20:53:57 -0600, Slava Bizyayev <[EMAIL PROTECTED]> wrote:
> Please Alex, "reply to all" in order to keep the thread on list.

Yikes! Sorry about that - I'm still not quite used to Gmail's interface!
 
> I believe that Ken Williams could give you a more precise advise since
> I'm always writing pure Apache handlers in similar cases, but just in
> order to give a quick try I would suggest to register the input too. I'm
> not quite sure, but to the best of my knowledge your script becomes a
> part of the Apache::RegistryFilter since you are inside the
> Apache::Filter chain, and you should get your input in accordance with
> the Apache::Filter rules. However, I might be wrong on that, and we'll
> have to wait for Ken then.

I tried adding "my ($fh, $status) = $r->filter_input();" to the
script, but got the same error.

After a bit of digging, I found someone else had the same "Not a HASH
reference" error, to which Ken said:

"This sounds like the error that would happen if AxKit used 
"$r = Apache->request" somewhere.  Apache->request is broken in terms of
subclassing - it won't return the subclass object."

I am getting $r from Apache->request. The reason I'm doing it this way
(rather than "$r = shift;" at the top of the module) is because our
application has a subroutine called print_content_type which is
invoked by all the other scripts / modules to send HTTP headers.
Currently it does this by just printing them directly out. I want to
make the changes in this subroutine only.

Is there an easier way to accomplish this, or is accessing
Apache->request the best way forward?


Thanks for your help so far,


-- Alex

> On Fri, 2004-12-24 at 19:59, Alex Greg wrote:
> > On 24 Dec 2004 18:47:15 -0600, Slava Bizyayev <[EMAIL PROTECTED]> wrote:
> > > Hi Alex,
> > >
> > > Your problem is originated from the fact that your code is not
> > > compatible with the Apache::Filter chain that you are trying to use.
> > > Apache::Dynagzip does not see your header because Apache::RegistryFilter
> > > does not allow it to get through. That's why Apache::Dynagzip sets up
> > > the default Content-Type.
> > >
> > > Please take a look at the Apache::Filter documentation in order to
> > > register you script with the Apache::RegistryFilter properly.
> >
> > Hi Slava,
> >
> >
> > Thanks for your reply. I've now registered my script with
> > Apache::Filter as follows:
> >
> >
> > #!/usr/local/bin/perl
> >
> > use strict;
> >
> > my $r = Apache->request;
> >
> > $r = $r->filter_register;
> >
> >
> > my $var;
> >
> > open(FILE, "text.txt");
> >
> > while (<FILE>)
> > {
> >         $var .= $_;
> > }
> >
> > close(FILE);
> >
> > $r->content_type("text/plain");
> > $r->send_http_header;
> >
> > print $var;
> >
> >
> > Unfortunately, I now get this in my error log:
> >
> >
> > Not a HASH reference at
> > /usr/lib/perl5/site_perl/5.8.3/Apache/Filter.pm line 197.
> >
> >
> > Any ideas?
> >
> >
> > Thanks,
> >
> >
> > -- Alex
> >
> >
> > > On Fri, 2004-12-24 at 17:34, Alex Greg wrote:
> > > > Hi,
> > > >
> > > >
> > > > I've been trying for most of the evening to get Apache::Dynagzip
> > > > working with Apache::Registry. I've gotten to the point whereby it
> > > > works fine (compresses the content or not depending on the browser),
> > > > but it sets the default Content-Type to text/html and disregards the
> > > > headers I send from my script.
> > > >
> > > >
> > > > The code below produces the following when called from a non-gzip 
> > > > browser:
> > > >
> > > >
> > > > #!/usr/local/bin/perl
> > > >
> > > > use strict;
> > > >
> > > > my $r = Apache->request;
> > > >
> > > > my $var;
> > > >
> > > > open(FILE, "text.txt");
> > > >
> > > > while (<FILE>)
> > > > {
> > > >         $var .= $_;
> > > > }
> > > >
> > > > close(FILE);
> > > >
> > > > $r->content_type("text/plain");
> > > > $r->send_http_header;
> > > >
> > > > print $var;
> > > >
> > > >
> > > > Response:
> > > >
> > > > Date: Fri, 24 Dec 2004 23:22:57 GMT
> > > > Server: Apache
> > > > X-Module-Sender: Apache::Dynagzip
> > > > Expires: Friday, 24-December-2004 23:27:57 GMT
> > > > Transfer-Encoding: chunked
> > > > Connection: close
> > > > Content-Type: text/html
> > > >
> > > > 213c
> > > > Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut tempor
> > > > bibendum ante. Donec rutrum. Cras semper neque in tellus. Pellentesque
> > > > blandit magna in nisl. Quisque dignissim cursus ligula. Curabitur
> > > > augue nunc, varius in, faucibus ac, ultrices quis, nisl.....
> > > >
> > > >
> > > > Note that Apache::Dynagzip is setting the header to the default
> > > > text/html even though I have explicitly set it to text/plain. The
> > > > following debug is from the error log:
> > > >
> > > >
> > > > [Fri Dec 24 23:29:10 2004] [info] [client 192.168.1.6]
> > > > Apache::Dynagzip default_content_handler is serving the main request
> > > > for GET /cgi-bin/blah.cgi HTTP/1.1 targeting /www/cgi-bin/blah.cgi via
> > > > /cgi-bin/blah.cgi Light Compression is Off. Source comes from Filter
> > > > Chain. The client  does not accept GZIP.
> > > > [Fri Dec 24 23:29:10 2004] [info] [client 192.168.1.6]
> > > > Apache::Dynagzip default_content_handler no gzip for GET
> > > > /cgi-bin/blah.cgi HTTP/1.1 min_chunk_size=8192
> > > > [Fri Dec 24 23:29:10 2004] [debug]
> > > > /usr/lib/perl5/site_perl/5.8.3/Apache/Dynagzip.pm(917): [client
> > > > 192.168.1.6] Apache::Dynagzip default_content_handler creates default
> > > > Content-Type for GET /cgi-bin/blah.cgi HTTP/1.1
> > > > [Fri Dec 24 23:29:10 2004] [info] [client 192.168.1.6]
> > > > Apache::Dynagzip default_content_handler is done OK for
> > > > /www/cgi-bin/blah.cgi 40172 bytes sent
> > > >
> > > >
> > > > What's even stranger is when I use the same check that Dynagzip uses
> > > > to see if the Content-Type is set, it fails. Appending this to my
> > > > script:
> > > >
> > > > if ($r->header_out("Content-type"))
> > > > {
> > > >         warn "Headers sent OK";
> > > > }
> > > > else
> > > > {
> > > >         warn "Headers NOT sent OK";
> > > > }
> > > >
> > > >
> > > > Results in the following in the error log:
> > > >
> > > >
> > > > Headers NOT sent OK at /www/cgi-bin/blah.cgi line 29.
> > > >
> > > >
> > > > My Apache configuration is as follows:
> > > >
> > > >
> > > > <Directory "/www/cgi-bin">
> > > >         SetHandler perl-script
> > > >         PerlHandler Apache::RegistryFilter Apache::Dynagzip
> > > >         PerlSetVar Filter On
> > > >         PerlSendHeader Off
> > > >         PerlSetupEnv On
> > > >         AllowOverride AuthConfig
> > > >         Options +ExecCGI
> > > > </Directory>
> > > >
> > > >
> > > > Any advice on this would be much appreciated, as I have been banging
> > > > my head against it all evening!
> > > >
> > > >
> > > > -- Alex
> > >
> > >
> 
>

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Reply via email to