1 package FS::Mason::Request;
5 use vars qw( $FSURL $QUERY_STRING );
6 use base 'HTML::Mason::Request';
8 use FS::access_user_log;
10 $FSURL = 'http://Set/FS_Mason_Request_FSURL/in_standalone_mode/';
16 FS::Trace->log('creating new FS::Mason::Request object');
18 my $superclass = $HTML::Mason::ApacheHandler::VERSION ?
19 'HTML::Mason::Request::ApacheHandler' :
20 $HTML::Mason::CGIHandler::VERSION ?
21 'HTML::Mason::Request::CGI' :
22 'HTML::Mason::Request';
24 FS::Trace->log(' altering superclass');
25 $class->alter_superclass( $superclass );
27 FS::Trace->log(' setting valid params');
28 #huh... shouldn't alter_superclass take care of this for us?
29 __PACKAGE__->valid_params( %{ $superclass->valid_params() } );
31 FS::Trace->log(' freeside_setup');
33 my $mode = $superclass =~ /Apache/i ? 'apache' : 'standalone';
34 $class->freeside_setup($opt{'comp'}, $mode);
36 FS::Trace->log(' SUPER::new');
37 $class->SUPER::new(@_);
41 #override alter_superclass ala RT::Interface::Web::Request ??
42 # for Mason 1.39 vs. Perl 5.10.0
47 my( $class, $filename, $mode ) = @_;
49 FS::Trace->log(' protecting fds');
51 #from rt/bin/webmux.pl(.in)
52 if ( !$protect_fds && $ENV{'MOD_PERL'} && exists $ENV{'MOD_PERL_API_VERSION'}
53 && $ENV{'MOD_PERL_API_VERSION'} >= 2
55 # under mod_perl2, STDIN and STDOUT get closed and re-opened,
56 # however they are not on FD 0 and 1. In this case, the next
57 # socket that gets opened will occupy one of these FDs, and make
58 # all system() and open "|-" calls dangerous; for example, the
59 # DBI handle can get this FD, which later system() calls will
60 # close by putting garbage into the socket.
62 push @{$protect_fds}, IO::Handle->new_from_fd(0, "r")
63 if fileno(STDIN) != 0;
64 push @{$protect_fds}, IO::Handle->new_from_fd(1, "w")
65 if fileno(STDOUT) != 1;
68 if ( $HTML::Mason::Commands::r ) {
69 FS::Trace->log(' adding headers');
70 #frame-ancestors not supported by all the major browsers yet
71 $HTML::Mason::Commands::r->header_out( 'X-Frame-Options', 'SAMEORIGIN' );
74 if ( $filename =~ qr(/REST/\d+\.\d+/NoAuth/) ) {
76 FS::Trace->log(' handling RT REST/NoAuth file');
78 package HTML::Mason::Commands; #?
79 use FS::UID qw( adminsuidsetup );
81 #need to log somebody in for the mail gw
83 ##old installs w/fs_selfs or selfserv??
84 #&adminsuidsetup('fs_selfservice');
86 FS::Trace->log(' adminsuidsetup fs_queue');
87 &adminsuidsetup('fs_queue');
91 FS::Trace->log(' handling regular file');
93 package HTML::Mason::Commands;
94 use vars qw( $cgi $p $fsurl ); # $lh ); #not using /mt
96 use FS::UID qw( cgisuidsetup );
97 use FS::CGI qw( popurl rooturl );
99 if ( $mode eq 'apache' ) {
101 FS::Trace->log(' cgisuidsetup');
106 } elsif ( $mode eq 'standalone' ) {
107 $cgi = new CGI $FS::Mason::Request::QUERY_STRING; #better keep setting
109 $FS::UID::cgi = $cgi;
110 $fsurl = $FS::Mason::Request::FSURL; #kludgy, but what the hell
111 $p = popurl(2, "$fsurl$filename");
113 die "unknown mode $mode";
116 FS::Trace->log(' UTF-8-decoding form data');
118 foreach my $param ( $cgi->param ) {
120 #we can't switch to multi_param until we're done supporting deb 7
121 local($CGI::LIST_CONTEXT_WARN) = 0;
123 my @values = $cgi->param($param);
124 next if $cgi->uploadInfo($values[0]);
126 @values = map decode(utf8=>$_), @values;
127 $cgi->param($param, @values);
132 FS::access_user_log->insert_new_path( $filename );
134 FS::Trace->log(' done');
139 RT::Interface::Web::Request::callback(@_);
143 RT::Interface::Web::Request::request_path(@_);