简体   繁体   中英

How to get QUERY_STRING in perl mason CGIHandler?

I need to do some maintenance on a Mason site that was working well at one hosting company, but needs to be moved to another. The new hosting company doesn't support ApacheHandler, so I'm changing the code to CGIHandler.

Unfortunately, I no longer get the QUERY_STRING elements populated into the mason environment, which makes it a little hard!

I got the bulk of the handler code from here: http://joe.pepersack.net/code/site-mason_handler.pl

The handler is being setup like this:

$h = HTML::Mason::CGIHandler->new(
  comp_root     => $mason_root,
  data_dir      => $mason_data,
  allow_globals => $::MASON_GLOBALS,
  error_mode    => "output",
  default_escape_flags => "h"
);

A general search of the internet doesn't return me anything good...

Does anyone know if there's a difference in parameter passing between ApacheHandler and CGIHandler? If they're being eaten somewhere else, how can I test whether CGIHandler found the params in the first place?

Any help (or additional leading questions) would be most appreciated. This site is for a youth fund-raiser, so there's not much time/support for rewriting it at the moment.

Based on this http://marc.info/?l=mason&m=96320172801620&w=3 ) and my experience it should be available in $ENV{QUERY_STRING}.

Maybe your setup tired to use it from Apache::Request directly or the CGI server does not set this automatically?

from http://cpansearch.perl.org/src/JSWARTZ/HTML-Mason-1.46/htdocs/CGIHandler.html :

This module also provides an $r request object for use inside components, similar to the Apache request object under HTML::Mason::ApacheHandler, but limited in functionality.

based on this: http://redmine.lighttpd.net/projects/lighttpd/wiki/MasonRecipe/11

### this seems to be necessary as lighttpd does not provide the PATH_INFO and the QUERY_STRING environment variables
## right' way to parse the REQUEST_URI out into PATH_INFO and QUERY_STRING
my $uri = $ENV{REQUEST_URI};
if ($uri =~ /\?/) {
  $uri =~ /^(.*?)\?(.*)/;
  $ENV{PATH_INFO} = $1;
  $ENV{QUERY_STRING} = $2;
} else {
  $ENV{PATH_INFO} = $uri;
  $ENV{QUERY_STRING} = "";
}

Thanks for the debugging help. Based on your ideas, I determined that $ENV{QUERY_STRING} wasn't available to mason, which made me go back and check apache. Sure enough, there was a rewrite rule that didn't have [QSA], so it was eating the query string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM