1

I am sending below http request

http://dummyServer.com/cgi-bin/swf/send.cgi?pname=PACKAGENAME&from=FROMADDRESS&to=TOADDRESS

Server is Apache

File : send.cgi

use CGI;
use lib '/Library/WebServer/CGI-Executables/swf/';
use My::XML qw(responce);

my $q = new CGI;
my $pname = $q->param("pname");
my $from = $q->param("from");
my $to = $q->param("to");

responce($pname, $from, $to);

File : My/XML.pm

package My::XML;
use XML::Writer;
use Exporter qw(import);
our @EXPORT_OK = qw(responce);
my $doc = new XML::Writer(DATA_MODE => 'true', DATA_INDENT => 2);

sub responce {
    my ($pname, $from, $to) = @_;
    $doc->startTag("details");
    $doc->dataElement( pname => "${pname}");
    $doc->dataElement( from => "${from}");
    $doc->dataElement( to => "${to}");
    $doc->endTag();
    $doc->end();
}
1;

send.cgi is working fine in cli getting correct xml output. But when i call the above http request i am getting 500 Internal Server. I should get the plain xml displayed on browser window.

Can anyone help in this

1 Answer 1

2

You still need to send a proper http header.

print "Content-Type: text/xml\n\n";

Since you're using CGI you can also output it this way:

print $q->header('text/xml');
Sign up to request clarification or add additional context in comments.

1 Comment

Or, given that he's using CGI.pm already, print $q->header(-content-type => "text/xml").

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.