diff options
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/CGI.pm | 7 | ||||
-rw-r--r-- | Bugzilla/Error.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Quantum.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Quantum/CGI.pm | 18 | ||||
-rw-r--r-- | Bugzilla/WebService/Server/JSONRPC.pm | 3 |
5 files changed, 21 insertions, 11 deletions
diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm index 1e070290e..8fae0c424 100644 --- a/Bugzilla/CGI.pm +++ b/Bugzilla/CGI.pm @@ -601,8 +601,11 @@ sub header { } my $headers = $self->SUPER::header(%headers) || ''; if ($self->server_software eq 'Bugzilla::Quantum::CGI') { - my $c = Bugzilla->request_cache->{mojo_controller}; + my $c = $Bugzilla::C; $c->res->headers->parse($headers); + if ($c->res->headers->status =~ /^([0-9]+)/) { + $c->res->code($1); + } return ''; } else { @@ -712,7 +715,7 @@ sub redirect { use Carp; carp "redirect @_\n"; if ($self->server_software eq 'Bugzilla::Quantum::CGI') { - my $c = Bugzilla->request_cache->{mojo_controller}; + my $c = $Bugzilla::C; $self->SUPER::redirect(@_); $c->redirect_to($c->res->headers->location); return ''; diff --git a/Bugzilla/Error.pm b/Bugzilla/Error.pm index bd2442410..9fcd16386 100644 --- a/Bugzilla/Error.pm +++ b/Bugzilla/Error.pm @@ -128,6 +128,7 @@ sub _throw_error { # of JSON::RPC. So, in that circumstance, instead of exiting, # we die with no message. JSON::RPC checks raise_error before # it checks $@, so it returns the proper error. + die if _in_eval(); $server->response($server->error_response_header); } } @@ -257,6 +258,7 @@ sub ThrowErrorPage { message => $message, id => $server->{_bz_request_id}, version => $server->version); + die if _in_eval(); $server->response($server->error_response_header); } } else { diff --git a/Bugzilla/Quantum.pm b/Bugzilla/Quantum.pm index df06da697..dfa22d824 100644 --- a/Bugzilla/Quantum.pm +++ b/Bugzilla/Quantum.pm @@ -48,7 +48,7 @@ sub startup { $r->any('/')->to('CGI#index_cgi'); $r->any('/rest')->to('CGI#rest_cgi'); - $r->any('/rest/*path_info')->to('CGI#rest_cgi'); + $r->any('/rest/*PATH_INFO')->to('CGI#rest_cgi'); $r->get( '/__lbheartbeat__' => sub { diff --git a/Bugzilla/Quantum/CGI.pm b/Bugzilla/Quantum/CGI.pm index 9b9af51de..aa1447c3e 100644 --- a/Bugzilla/Quantum/CGI.pm +++ b/Bugzilla/Quantum/CGI.pm @@ -17,8 +17,8 @@ use Sub::Quote 2.005000; use Try::Tiny; use Taint::Util qw(untaint); use Socket qw(AF_INET inet_aton); -use Capture::Tiny qw(capture_stdout); use Sys::Hostname; +use English qw(-no_match_vars); sub load_all { my ($class, $r) = @_; @@ -60,24 +60,24 @@ sub _load_cgi { my ($c) = @_; my $stdin = $c->_STDIN; my $stdout = ''; + local $Bugzilla::C = $c; local %ENV = $c->_ENV; local *STDIN; ## no critic (local) + local *STDOUT; ## no critic (local) local $CGI::Compile::USE_REAL_EXIT = 0; + local $PROGRAM_NAME = $file; open STDIN, '<', $stdin->path or die "STDIN @{[$stdin->path]}: $!" if -s $stdin->path; + open STDOUT, '>', \$stdout or die "STDOUT capture: $!"; try { Bugzilla->init_page(); - Bugzilla->request_cache->{mojo_controller} = $c; - $stdout = capture_stdout \&$inner; + $inner->(); } catch { + $c->render(text => $_); die $_ unless ref $_ eq 'ARRAY' && $_->[0] eq "EXIT\n" || /\bModPerl::Util::exit\b/; } finally { - if ( length $stdout ) { - warn "setting body\n"; - $c->res->body($stdout); - $c->rendered; - } + $c->res->body($stdout) if $stdout Bugzilla->_cleanup; ## no critic (private) CGI::initialize_globals(); }; @@ -107,6 +107,7 @@ sub _ENV { $remote_user = $authenticate =~ /Basic\s+(.*)/ ? b64_decode $1 : ''; $remote_user = $remote_user =~ /([^:]+)/ ? $1 : ''; } + my $path_info = $c->stash('PATH_INFO') || ''; return ( CONTENT_LENGTH => $content_length || 0, @@ -115,6 +116,7 @@ sub _ENV { HTTPS => $req->is_secure ? 'YES' : 'NO', %env_headers, QUERY_STRING => $c->stash('cgi.query_string') || $req->url->query->to_string, + PATH_INFO => $path_info ? "/$path_info" : '', REMOTE_ADDR => $tx->remote_address, REMOTE_HOST => gethostbyaddr( inet_aton( $tx->remote_address || '127.0.0.1' ), AF_INET ) || '', REMOTE_PORT => $tx->remote_port, diff --git a/Bugzilla/WebService/Server/JSONRPC.pm b/Bugzilla/WebService/Server/JSONRPC.pm index 093167048..9253053ce 100644 --- a/Bugzilla/WebService/Server/JSONRPC.pm +++ b/Bugzilla/WebService/Server/JSONRPC.pm @@ -112,6 +112,9 @@ sub response { print $cgi->header(-status => $response->code, @header_args); print $response->content; } + if ($cgi->server_software eq 'Bugzilla::Quantum::CGI') { + $Bugzilla::C->rendered; + } } # The JSON-RPC 1.1 GET specification is not so great--you can't specify |