diff options
author | Dylan William Hardison <dylan@hardison.net> | 2018-10-03 02:25:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-03 02:25:35 +0200 |
commit | 683d8b3fd64f9baf467d8b659dec1ca7796b429d (patch) | |
tree | a728fe08764c3c92e3daeb3b4ec70f2072442be3 /xmlrpc.cgi | |
parent | 286637cf16f1b933e8d4e14a4be4ca7123866374 (diff) | |
download | bugzilla-683d8b3fd64f9baf467d8b659dec1ca7796b429d.tar.gz bugzilla-683d8b3fd64f9baf467d8b659dec1ca7796b429d.tar.xz |
Bug 1495834 - xmlrpc.cgi outputs headers in request-body
Diffstat (limited to 'xmlrpc.cgi')
-rwxr-xr-x | xmlrpc.cgi | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/xmlrpc.cgi b/xmlrpc.cgi index 07c1020aa..620187e5a 100755 --- a/xmlrpc.cgi +++ b/xmlrpc.cgi @@ -16,27 +16,43 @@ use Bugzilla; use Bugzilla::Constants; use Bugzilla::Error; use Bugzilla::WebService::Constants; +use Capture::Tiny qw(capture_stdout); + BEGIN { - if (!Bugzilla->feature('xmlrpc')) { - ThrowCodeError('feature_disabled', { feature => 'xmlrpc' }); - } + if (!Bugzilla->feature('xmlrpc')) { + ThrowCodeError('feature_disabled', {feature => 'xmlrpc'}); + } } use Bugzilla::WebService::Server::XMLRPC; -Bugzilla->usage_mode(USAGE_MODE_XMLRPC); +my $stdout = capture_stdout { + Bugzilla->usage_mode(USAGE_MODE_XMLRPC); # Fix the error code that SOAP::Lite uses for Perl errors. -local $SOAP::Constants::FAULT_SERVER; -$SOAP::Constants::FAULT_SERVER = ERROR_UNKNOWN_FATAL; + local $SOAP::Constants::FAULT_SERVER; + $SOAP::Constants::FAULT_SERVER = ERROR_UNKNOWN_FATAL; + # The line above is used, this one is ignored, but SOAP::Lite # might start using this constant (the correct one) for XML-RPC someday. -local $XMLRPC::Constants::FAULT_SERVER; -$XMLRPC::Constants::FAULT_SERVER = ERROR_UNKNOWN_FATAL; + local $XMLRPC::Constants::FAULT_SERVER; + $XMLRPC::Constants::FAULT_SERVER = ERROR_UNKNOWN_FATAL; + + local @INC = (bz_locations()->{extensionsdir}, @INC); + my $server = new Bugzilla::WebService::Server::XMLRPC; -local @INC = (bz_locations()->{extensionsdir}, @INC); -my $server = new Bugzilla::WebService::Server::XMLRPC; # We use a sub for on_action because that gets us the info about what # class is being called. Note that this is a hack--this is technically # for setting SOAPAction, which isn't used by XML-RPC. -$server->on_action(sub { $server->handle_login(WS_DISPATCH, @_) }) - ->handle(); + $server->on_action(sub { $server->handle_login(WS_DISPATCH, @_) })->handle(); +}; +my $C = $Bugzilla::Quantum::CGI::C; +my ($header_str, $body) = split(/(?:\r\n\r\n|\n\n)/, $stdout, 2); +my $headers = Mojo::Headers->new; +$headers->parse("$header_str\r\n\r\n"); +foreach my $name (@{$headers->names}) { + $C->res->headers->header($name => $headers->header($name)); +} +my ($code) = $headers->header('Status') =~ /^(\d+)/; +$C->res->code($code) if $code; +$C->write($body); +exit; |