Skip Menu |

This queue is for tickets about the JSON-RPC CPAN distribution.

Report information
The Basics
Id: 55730
Status: new
Priority: 0/
Queue: JSON-RPC

People
Owner: Nobody in particular
Requestors: mkanat [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.96
Fixed in: (no value)



Subject: JSON::RPC::Server::CGI should be using CGI.pm to send headers
Right now JSON::RPC::Server::CGI uses CGI.pm to do all sorts of stuff about processing the request, but it doesn't use it to send back headers. Using CGI.pm to send back headers allows it to work in different sorts of situations, including situations (like mine) where we've overridden $self->cgi to our own CGI.pm subclass, and it creates headers differently. Attached is a patch that does this.
Subject: json-rpc-cgi.diff
--- CGI.pm.old 2010-03-19 22:59:03.000000000 -0700 +++ CGI.pm 2010-03-19 23:00:00.000000000 -0700 @@ -54,11 +54,20 @@ sub response { my ($self, $response) = @_; - print "Status: " . $response->code . "\015\012" . $response->headers_as_string("\015\012") - . "\015\012" . $response->content; + 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 cgi { $_[0]->{cgi} ||= new CGI; }