nijin has asked for the wisdom of the Perl Monks concerning the following question:
In my Apache configuration file I have following directives.Status: 200 Content-Type: application/json; charset=UTF-8
My cgi script is pasted below.LoadModule perl_module modules/mod_perl.so PerlSwitches -w PerlSwitches -T Alias /perl /var/www/html/perl <Directory /var/www/html/perl> SetHandler perl-script PerlResponseHandler ModPerl::Registry Options +ExecCGI </Directory>
My client side script is#!/usr/bin/perl use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use JSON::RPC::Server::CGI; use strict; use Data::Dumper; my $server = JSON::RPC::Server::CGI->new; $server->dispatch('Myapp')->handle(); The Myapp.pm is #!/usr/bin/perl package Myapp; use base qw(JSON::RPC::Procedure); # Perl 5.6 or more than use strict; use Data::Dumper; sub test : Public(u1:str){ my ($s, $obj) = @_; my $u1 = $obj->{u1}; return $u1; } 1;
In normal case the output should be testing . But in my case I am getting the below error.#!/usr/bin/perl use JSON::RPC::Client; use Data::Dumper; my $client = new JSON::RPC::Client; my $uri = 'http://IP/perl/test.cgi'; $client->prepare($uri, ['test']); $str= $client->test('testing'); print "$str\n\n";
The issue is because some http headers are automatically get added to the return value. Is there any way to suppress these headers? Note: Kindly don't recommend normal cgi scripts or running perl script as daemon because it is already working and tested from my end. We are using mod_perl for high performance.malformed JSON string, neither array, object, number, string or atom, +at character offset 0 (before "Status: 200\r\nConte...") at /usr/loca +l/share/perl5/JSON/RPC/Client.pm line 186
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Issue in Json RPC with mod_perl
by Corion (Patriarch) on Jul 04, 2014 at 13:51 UTC | |
|
Re: Issue in Json RPC with mod_perl
by hippo (Archbishop) on Jul 04, 2014 at 13:29 UTC | |
by nijin (Initiate) on Jul 04, 2014 at 13:43 UTC | |
by hippo (Archbishop) on Jul 04, 2014 at 14:07 UTC |