From: Max Kanat-Alexander Date: Tue, 23 Mar 2010 23:12:29 +0000 (-0700) Subject: Bug 553774: Make User.login correctly return cookies under JSON-RPC X-Git-Tag: bugzilla-3.6~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3fde0cce7cba6a5e621b87bcc3fa6a9c12af5afd;p=thirdparty%2Fbugzilla.git Bug 553774: Make User.login correctly return cookies under JSON-RPC r=dkl, a=mkanat --- diff --git a/Bugzilla/WebService/Server/JSONRPC.pm b/Bugzilla/WebService/Server/JSONRPC.pm index d07901a7f4..3ec64c6bc9 100644 --- a/Bugzilla/WebService/Server/JSONRPC.pm +++ b/Bugzilla/WebService/Server/JSONRPC.pm @@ -52,6 +52,25 @@ sub create_json_coder { # Override the JSON::RPC method to return our CGI object instead of theirs. sub cgi { return Bugzilla->cgi; } +# Override the JSON::RPC method to use $cgi->header properly instead of +# just printing text directly. This fixes various problems, including +# sending Bugzilla's cookies properly. +sub response { + my ($self, $response) = @_; + my $headers = $response->headers; + my @header_args; + foreach my $name ($headers->header_field_names) { + my @values = $headers->header($name); + $name =~ s/-/_/g; + foreach my $value (@values) { + push(@header_args, "-$name", $value); + } + } + my $cgi = $self->cgi; + print $cgi->header(-status => $response->code, @header_args); + print $response->content; +} + sub type { my ($self, $type, $value) = @_;