diff options
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/CGI.pm | 18 | ||||
-rw-r--r-- | Bugzilla/Quantum.pm | 7 | ||||
-rw-r--r-- | Bugzilla/Quantum/Plugin/Glue.pm | 32 |
3 files changed, 45 insertions, 12 deletions
diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm index 78037292a..d43a26eab 100644 --- a/Bugzilla/CGI.pm +++ b/Bugzilla/CGI.pm @@ -94,7 +94,7 @@ sub new { # Under mod_perl, CGI's global variables get reset on each request, # so we need to set them up again every time. - $class->_init_bz_cgi_globals() if $ENV{MOD_PERL}; + $class->_init_bz_cgi_globals(); my $self = $class->SUPER::new(@args); @@ -561,10 +561,10 @@ sub header { } } my $headers = $self->SUPER::header(%headers) || ''; - + warn "if (". $self->server_software." eq 'Bugzilla::Quantum::Plugin::Glue') {"; if ($self->server_software eq 'Bugzilla::Quantum::Plugin::Glue') { - my $c = Bugzilla::request_cache->{mojo_controller}; - $c->res->headers(Mojo::Headers->parse($headers)); + my $c = Bugzilla->request_cache->{mojo_controller}; + $c->res->headers(Mojo::Headers->new->parse($headers)) if $headers; return ''; } else { @@ -671,7 +671,15 @@ sub send_cookie { sub redirect { my $self = shift; $self->{bz_redirecting} = 1; - return $self->SUPER::redirect(@_); + warn "redirect: @_\n"; + if ($self->server_software eq 'Bugzilla::Quantum::Plugin::Glue') { + my $c = Bugzilla->request_cache->{mojo_controller}; + $c->redirect_to(@_); + return ''; + } + else { + return $self->SUPER::redirect(@_); + } } # This helps implement Bugzilla::Search::Recent, and also shortens search diff --git a/Bugzilla/Quantum.pm b/Bugzilla/Quantum.pm index 7270ada55..3f197a508 100644 --- a/Bugzilla/Quantum.pm +++ b/Bugzilla/Quantum.pm @@ -9,9 +9,8 @@ package Bugzilla::Quantum; use Mojo::Base 'Mojolicious'; use CGI::Compile; # Primarily for its exit overload. -use Bugzilla::Quantum::CGI; use Bugzilla::Quantum::Template; -use Bugzilla::Quantum::Legacy; +use Bugzilla::Quantum::CGI; use Bugzilla::Quantum::Static; use Bugzilla::PSGI qw(compile_cgi); @@ -62,9 +61,9 @@ rewrite => 1, } ); my $r = $self->routes; - Bugzilla::Quantum::Legacy->expose_routes($r); + Bugzilla::Quantum::CGI->expose_routes($r); - $r->any('/')->to('Legacy#index_cgi'); + $r->any('/')->to('CGI#handle_index'); $r->get( '/__lbheartbeat__' => sub { diff --git a/Bugzilla/Quantum/Plugin/Glue.pm b/Bugzilla/Quantum/Plugin/Glue.pm index abada14f8..2e3ecf4f0 100644 --- a/Bugzilla/Quantum/Plugin/Glue.pm +++ b/Bugzilla/Quantum/Plugin/Glue.pm @@ -26,10 +26,12 @@ sub register { my %params; # Helpers + my %helper; foreach my $method ( grep {m/^\w+\z/} keys %{ $renderer->helpers } ) { my $sub = $renderer->helpers->{$method}; - $params{$method} = sub { $c->$sub(@_) }; + $helper{$method} = sub { $c->$sub(@_) }; } + $params{helper} = \%helper; # Stash values $params{$_} = $c->stash->{$_} for grep {m/^\w+\z/} keys %{ $c->stash }; @@ -49,11 +51,16 @@ sub register { try { local $CGI::Compile::USE_REAL_EXIT = 0; local %ENV = _ENV($c); + my $stdin = _STDIN($c); + warn "stdin path ", $stdin->path, "\n"; + local *STDIN; + open STDIN, '<', $stdin->path or die "STDIN @{[$stdin->path]}: $!" if -s $stdin->path; Bugzilla::init_page(); - Bugzilla::request_cache->{mojo_controller} = $c; + Bugzilla->request_cache->{mojo_controller} = $c; Bugzilla->template( Bugzilla::Quantum::Template->new( controller => $c, template => $template ) ); $next->(); Bugzilla::_cleanup; ## no critic (private) + CGI::initialize_globals(); } catch { die $_ unless ref $_ eq 'ARRAY' && $_->[0] eq "EXIT\n" || /\bModPerl::Util::exit\b/; }; @@ -75,6 +82,7 @@ sub _ENV { $env_headers{$key} = $headers->header($name); } + my $remote_user; if ( my $userinfo = $c->req->url->to_abs->userinfo ) { $remote_user = $userinfo =~ /([^:]+)/ ? $1 : ''; } @@ -95,11 +103,29 @@ sub _ENV { REMOTE_PORT => $tx->remote_port, REMOTE_USER => $remote_user || '', REQUEST_METHOD => $req->method, - SCRIPT_NAME => $req->env->{SCRIPT_NAME} SERVER_NAME => hostname, + SCRIPT_NAME => $req->env->{SCRIPT_NAME}, + SERVER_NAME => hostname, SERVER_PORT => $tx->local_port, SERVER_PROTOCOL => $req->is_secure ? 'HTTPS' : 'HTTP', # TODO: Version is missing SERVER_SOFTWARE => __PACKAGE__, ); } +sub _STDIN { + my $c = shift; + my $stdin; + + if ( $c->req->content->is_multipart ) { + $stdin = Mojo::Asset::File->new; + $stdin->add_chunk( $c->req->build_body ); + } + else { + $stdin = $c->req->content->asset; + } + + return $stdin if $stdin->isa('Mojo::Asset::File'); + return Mojo::Asset::File->new->add_chunk( $stdin->slurp ); +} + + 1;
\ No newline at end of file |