summaryrefslogtreecommitdiffstats
path: root/Bugzilla/CGI.pm
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2016-11-12 17:41:08 +0100
committerDylan William Hardison <dylan@hardison.net>2016-11-12 17:41:20 +0100
commit874e96c2423c772564c9dc63254baa99e86f270b (patch)
tree21e396b52b8fa54a3da946b90f5242992e660aee /Bugzilla/CGI.pm
parent085878323cb82810bc2cd3f00ce925bb49c70156 (diff)
downloadbugzilla-874e96c2423c772564c9dc63254baa99e86f270b.tar.gz
bugzilla-874e96c2423c772564c9dc63254baa99e86f270b.tar.xz
Bug 1314201 - ThrowUserError and ThrowCodeError should print headers if headers have not already been printed
Diffstat (limited to 'Bugzilla/CGI.pm')
-rw-r--r--Bugzilla/CGI.pm23
1 files changed, 19 insertions, 4 deletions
diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm
index 78987ab71..ec8b8e52b 100644
--- a/Bugzilla/CGI.pm
+++ b/Bugzilla/CGI.pm
@@ -21,6 +21,7 @@ use Bugzilla::Search::Recent;
use File::Basename;
use URI;
+use Carp qw(cluck);
BEGIN {
if (ON_WINDOWS) {
@@ -306,7 +307,6 @@ sub check_etag {
return 0;
}
-# Overwrite to ensure nph doesn't get set, and unset HEADERS_ONCE
sub multipart_init {
my $self = shift;
@@ -330,6 +330,7 @@ sub multipart_init {
# CGI.pm's header() sets nph according to a param or $CGI::NPH, which
# is the desired behaviour.
+ $self->{_bz_multipart} = 1;
return $self->header(
%param,
) . "WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY." . $self->multipart_end;
@@ -384,7 +385,12 @@ sub header {
my %headers;
my $user = Bugzilla->user;
- # If there's only one parameter, then it's a Content-Type.
+ if ($self->{_bz_headers_sent} && !$self->{_bz_multipart}) {
+ # cluck for the warning log so we can see where this was called.
+ cluck "attempt to send headers after headers already sent!";
+ ThrowCodeError("headers_already_sent");
+ }
+
if (scalar(@_) == 1) {
%headers = ('-type' => shift(@_));
}
@@ -460,9 +466,18 @@ sub header {
Bugzilla::Hook::process('cgi_headers',
{ cgi => $self, headers => \%headers }
);
- $self->{_header_done} = 1;
- return $self->SUPER::header(%headers) || "";
+ my $headers = $self->SUPER::header(%headers) || "";
+ if ($headers && Bugzilla->usage_mode != USAGE_MODE_XMLRPC) {
+ $self->{_bz_headers_sent} = 1;
+ }
+
+ return $headers;
+}
+
+sub sent_headers {
+ my ($self) = @_;
+ return $self->{_bz_headers_sent};
}
sub param {