Closed Bug 895306 Opened 11 years ago Closed 11 years ago

REST endpoint returns both JSON and HTML errors when running under mod_perl

Categories

(Bugzilla :: WebService, defect)

defect
Not set
major

Tracking

()

RESOLVED FIXED
Bugzilla 5.0

People

(Reporter: glob, Assigned: glob)

References

Details

Attachments

(1 file)

Attached patch patch v1Splinter Review
REST endpoint returns both JSON and HTML errors when running under mod_perl.

this is because the mod_perl response handler is returning a valid http error code.  this patch hacks around that, however there may be a cleaner way to address this issue.
Attachment #777648 - Flags: review?(dkl)
Comment on attachment 777648 [details] [diff] [review]
patch v1

Review of attachment 777648 [details] [diff] [review]:
-----------------------------------------------------------------

Better to use Bugzilla->usage_mode instead of substr().

=== modified file 'mod_perl.pl'
--- mod_perl.pl	2012-12-01 01:18:21 +0000
+++ mod_perl.pl	2013-07-18 16:46:41 +0000
@@ -115,6 +115,7 @@
 
 use parent qw(ModPerl::Registry);
 use Bugzilla;
+use Bugzilla::Constants;
 
 sub handler : method {
     my $class = shift;
@@ -132,7 +133,13 @@
     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;
 }

Fix on checkin. r=dkl
Attachment #777648 - Flags: review?(dkl) → review+
Flags: approval?
Flags: approval? → approval+
Target Milestone: --- → Bugzilla 5.0
Committing to: bzr+ssh://bjones%40mozilla.com@bzr.mozilla.org/bugzilla/trunk/
modified mod_perl.pl
Committed revision 8651.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: