http://www.perlmonks.org?node_id=180448

hackmare has asked for the wisdom of the Perl Monks concerning the following question:

Bretheren,

I am trying to use HTTP::Daemon to return an XML snippet (SVG) generated with SVG.pm.

I am finding myself unable to return the complete XML message when I generate it. When I print the content of my XML to log, I get the entire, fully-qualified string. However, when I try to implement

$c->send_response($string);

where $string is a complete XML message, I only get the last snippet of XML (3-4 lines of comments at the bottom of the file.

So my Big Question is, how do I send XML content using HTTP::Daemon ? I'd appreciate any help on this...

use HTTP::Daemon; use HTTP::Status; use SVG; my $d = new HTTP::Daemon; print "Please contact me at: <URL:", $d->url, ">\n"; while (my $c = $d->accept) { while (my $r = $c->get_request) { my $svg = SVG->new(width=>'100%',height=>'100%'); my $g = $svg->group(id=>'group-1'); $g->circle(id=>'circle-1', cx=>int(rand(400)), cy=>int(rand(400)), r=>int(rand(100)),); if ($r->method eq 'GET') { my $path = $r->url->path; $path =~ /\/(.+)/; $sessionid = $1 || '00'; $g->text(x=>int(rand(400)), y=>int(rand(400))) ->cdata($sessionid); $c->send_response($svg->xmlify()); } else { $c->send_error(RC_FORBIDDEN) } } $c->close; undef($c); }

hackmare.