AMF-Perl
view release on metacpan or search on metacpan
lib/AMF/Perl.pm view on Meta::CPAN
=over 4
=item Changed "use Apache2" to "require Apache2" to avoid breaking on non-modperl systems.
=back
=head2 Sat Apr 24 20:41:10 EDT 2004
=over 4
=item Another patch from Kostas Chatzikokolakis fixing MP2 issues.
=back
=head2 Sat Mar 13 16:25:00 EST 2004
=over 4
=item Patch from Kostas Chatzikokolakis handling encoding.
=item Changed non-mod_perl behavior for reading POST data from using <> to using read()
to work around a bug in IIS
=item Joined code for mod_perl 1 and 2. Separated the output code for the mod_perl and non-mod_perl
cases.
=back
=head2 Sat Aug 2 14:01:15 EDT 2003
=over 4
=item Changed new() to be invokable on objects, not just strings.
=back
=head2 Sun Jul 20 19:27:44 EDT 2003
=over 4
=item Added "binmode STDIN" before reading input to prevent treating 0x1a as EOF on Windows.
=back
=head2 Wed Apr 23 19:22:56 EDT 2003
=over 4
=item Added "binmode STDOUT" before printing headers to prevent conversion of 0a to 0d0a on Windows.
=item Added modperl 1 support and (so far commented out) hypothetical modperl 2 support.
=back
=head2 Sun Mar 23 13:27:00 EST 2003
=over 4
=item Synching with AMF-PHP:
Added functions debugDir() and log() (debug() in PHP), added reading headers to service().
Added fromFile() to enable parsing traffic dumps.
=back
=cut
use Devel::StackTrace;
use Exception::Class ('AMFException');
# load the required system packagees
use AMF::Perl::IO::InputStream;
use AMF::Perl::IO::Deserializer;
use AMF::Perl::App::Executive;
use AMF::Perl::IO::Serializer;
use AMF::Perl::IO::OutputStream;
use AMF::Perl::Util::Object;
# constructor
sub new
{
my ($proto) = @_;
my $class = ref($proto) || $proto;
my $self = {};
bless $self, $class;
$self->{exec} = new AMF::Perl::App::Executive();
$self->{"response"} = "/onResult";
$self->{debug}=0;
return $self;
}
sub debug
{
my $self = shift;
if (@_) {$self->{debug} = shift;}
return $self->{debug};
}
sub service
{
my ($self)=@_;
my $inputStream;
my $content = "";
#Otherwise Apache on Windows treats 0x1a as EOF.
binmode STDIN;
if($ENV{MOD_PERL})
{
require mod_perl;
my $MP2 = ($mod_perl::VERSION >= 1.99);
if ($MP2)
{
require Apache2;
require Apache::RequestUtil; # needed for Apache->request
}
my $r = Apache->request();
$r->read($content, $r->headers_in->{'Content-Length'});
}
else
lib/AMF/Perl.pm view on Meta::CPAN
{
my $self = shift;
$self->{encoding} = shift if @_;
return $self->{encoding};
}
# usefulldebugging method
# You can save the raw data sent from the
# flash client by calling
# $self->_saveRawDataToFile("file.amf", $contents);
sub _saveRawDataToFile
{
my ($self, $filepath, $data)=@_;
# open the file for writing
if (!open(HANDLE, "> $filepath"))
{
die "Could not open file $filepath: $!\n";
}
# write to the file
if (!print HANDLE $data)
{
die "Could not print to file $filepath: $!\n";
}
# close the file resource
close HANDLE;
}
sub _appendRawDataToFile
{
my ($self, $filepath, $data) = @_;
# open the file for writing
if (!open (HANDLE, ">>$filepath"))
{
die "Could not open file $filepath: $!\n";
}
# write to the file
if (!print HANDLE $data)
{
die "Could not print to file $filepath: $!\n";
}
# close the file resource
close HANDLE;
}
# get contents of a file into a string
sub _loadRawDataFromFile
{
my ($self, $filepath)=@_;
# open a handle to the file
open (HANDLE, $filepath);
# read the entire file contents
my @contents = <HANDLE>;
# close the file handle
close HANDLE;
# return the contents
return join "", @contents;
}
sub log
{
my ($self, $content) = @_;
$self->_appendRawDataToFile ($self->debugDir."processing.txt",$content."\n");
}
1;
__END__
( run in 0.748 second using v1.01-cache-2.11-cpan-39bf76dae61 )