summaryrefslogtreecommitdiffstats
path: root/Bugzilla/WebService/Server
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-10-13 06:32:57 +0200
committerGitHub <noreply@github.com>2018-10-13 06:32:57 +0200
commit5688d0e712b85bc892ce405a1b79e3571f6d6d0f (patch)
tree39277970bd3648781fbecd1ebdcc9b3d6693d4b9 /Bugzilla/WebService/Server
parent9263b7453169816c23b6f307fd225f3676d57a3a (diff)
downloadbugzilla-5688d0e712b85bc892ce405a1b79e3571f6d6d0f.tar.gz
bugzilla-5688d0e712b85bc892ce405a1b79e3571f6d6d0f.tar.xz
Bug 1495741 - memory issues: Avoid copying stuff in the webservice layer so much
Diffstat (limited to 'Bugzilla/WebService/Server')
-rw-r--r--Bugzilla/WebService/Server/JSONRPC.pm14
-rw-r--r--Bugzilla/WebService/Server/REST.pm1
2 files changed, 13 insertions, 2 deletions
diff --git a/Bugzilla/WebService/Server/JSONRPC.pm b/Bugzilla/WebService/Server/JSONRPC.pm
index 093167048..12a3143cc 100644
--- a/Bugzilla/WebService/Server/JSONRPC.pm
+++ b/Bugzilla/WebService/Server/JSONRPC.pm
@@ -31,7 +31,9 @@ use Bugzilla::Util;
use HTTP::Message;
use MIME::Base64 qw(decode_base64 encode_base64);
+use Scalar::Util qw(blessed);
use List::MoreUtils qw(none);
+use Bugzilla::WebService::JSON;
#####################################
# Public JSON::RPC Method Overrides #
@@ -48,7 +50,7 @@ sub new {
sub create_json_coder {
my $self = shift;
- my $json = $self->SUPER::create_json_coder(@_);
+ my $json = Bugzilla::WebService::JSON->new;
$json->allow_blessed(1);
$json->convert_blessed(1);
$json->allow_nonref(1);
@@ -83,6 +85,9 @@ sub response {
# Implement JSONP.
if (my $callback = $self->_bz_callback) {
my $content = $response->content;
+ if (blessed $content) {
+ $content = $content->encode;
+ }
# Prepend the JSONP response with /**/ in order to protect
# against possible encoding attacks (e.g., affecting Flash).
$response->content("/**/$callback($content)");
@@ -110,7 +115,12 @@ sub response {
else {
push(@header_args, "-ETag", $etag) if $etag;
print $cgi->header(-status => $response->code, @header_args);
- print $response->content;
+ my $content = $response->content;
+ if (blessed $content) {
+ $content = $content->encode;
+ utf8::encode($content);
+ }
+ print $content;
}
}
diff --git a/Bugzilla/WebService/Server/REST.pm b/Bugzilla/WebService/Server/REST.pm
index 13896b248..5d8367410 100644
--- a/Bugzilla/WebService/Server/REST.pm
+++ b/Bugzilla/WebService/Server/REST.pm
@@ -165,6 +165,7 @@ sub response {
my $template = Bugzilla->template;
$content = "";
+ $result->encode if blessed $result;
$template->process("rest.html.tmpl", { result => $result }, \$content)
|| ThrowTemplateError($template->error());