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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.