NAME
Froody::Response::String - create a response from a string
SYNOPSIS
my $response = Froody::Response::String->new()
->structure($froody_method)
->set_string($string)
print $response->render;
DESCRIPTION
This is a concrete implementation of Froody::Response. It takes its input from a valid Perl string, which you can set with set_string
:
my $frs = Froody::Response::String->new();
$frs->structure($froody_method);
$frs->set_string( <<ENDOFRSP );
<rsp stat="ok">
<monger>L\x{e9}on Brocard</monger>
</rsp>
ENDOFRSP
Note that there's no XML declaration header there - one will be added automatically. You can also set the bytes directly:
my $frs = Froody::Response::String->new();
$frs->structure($froody_method);
$frs->set_bytes( <<ENDOFRSP );
<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="ok">
<monger>L\x{c3}\x{a9}on Brocard</monger>
</rsp>
ENDOFRSP
In this case you are required to include the XML declaration header (as we can't create one for you as we have no idea what encoding scheme the bytes are using)
Converting other Responses to Froody::Response::String objects
Once you've loaded this class you can automatically convert other Froody::Response class instances to Froody::Response::String objects with the as_string
method.
use Froody::Response::String;
my $string = Froody::Response::Terse
->new()
->structure($froody_method)
->content(...)
->as_string;
print ref($string); # prints "Froody::Response::String"
BUGS
None known.
Please report any bugs you find via the CPAN RT system. http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Froody
AUTHOR
Copyright Fotango 2005. All rights reserved.
Please see the main Froody documentation for details of who has worked on this project.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.