]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 895306: REST endpoint returns both JSON and HTML errors when running under mod_perl
authorByron Jones <bjones@mozilla.com>
Mon, 22 Jul 2013 05:14:38 +0000 (13:14 +0800)
committerByron Jones <bjones@mozilla.com>
Mon, 22 Jul 2013 05:14:38 +0000 (13:14 +0800)
r=dkl, a=glob

mod_perl.pl

index 20b9746f39e45d3f33def0e0209838e106043939..1f4593f009cc403d2868d396e177f8696d305265 100644 (file)
@@ -115,6 +115,7 @@ use strict;
 
 use parent qw(ModPerl::Registry);
 use Bugzilla;
+use Bugzilla::Constants qw(USAGE_MODE_REST);
 
 sub handler : method {
     my $class = shift;
@@ -132,7 +133,13 @@ sub handler : method {
     use warnings;
 
     Bugzilla::init_page();
-    return $class->SUPER::handler(@_);
+    my $result = $class->SUPER::handler(@_);
+
+    # When returning data from the REST api, tell Apache not to append its
+    # error html documents to the response.
+    return Bugzilla->usage_mode == USAGE_MODE_REST
+           ? Apache2::Const::OK
+           : $result;
 }