This file is indexed.

/usr/share/perl5/Data/AMF/Packet.pm is in libdata-amf-perl 0.09-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
package Data::AMF::Packet;
use Any::Moose;

require bytes;
use Data::AMF::Parser;
use Data::AMF::Formatter;
use Data::AMF::IO;

use Data::AMF::Header;
use Data::AMF::Message;

has version => (
	is      => 'rw',
	isa     => 'Int',
	lazy    => 1,
	default => sub { 0 },
);

has headers => (
	is      => 'rw',
	isa     => 'ArrayRef',
	lazy    => 1,
	default => sub { [] },
);

has messages => (
	is      => 'rw',
	isa     => 'ArrayRef',
	lazy    => 1,
	default => sub { [] },
);

no Any::Moose;

sub deserialize
{
	my ($class, $data) = @_;

	my $io = Data::AMF::IO->new(data => $data);

	my $ver           = $io->read_u16;
	my $header_count  = $io->read_u16;
	my $message_count = $io->read_u16;

	my $parser = Data::AMF::Parser->new(version => 0);

	my @headers;
	for my $i (1 .. $header_count)
	{
		my $name  = $io->read_utf8;
		my $must  = $io->read_u32;
		my $len   = $io->read_u32;

		my $data    = $io->read($len);
		my ($value) = $parser->parse($data);

		push @headers, Data::AMF::Header->new(
			name            => $name,
			must_understand => $must,
			value           => $value,
			version         => $ver,
		);
	}

	my @messages;
	for my $i (1 .. $message_count)
	{
		my $target_uri   = $io->read_utf8;
		my $response_uri = $io->read_utf8;
		my $len		  = $io->read_u32;

		my $data    = $io->read($len);
		my ($value) = $parser->parse($data);

		push @messages, Data::AMF::Message->new(
			target_uri   => $target_uri,
			response_uri => $response_uri,
			value        => $value,
			version      => $ver,
			source       => $data
		);
	}

	return Data::AMF::Packet->new(
		version  => $ver,
		headers  => \@headers,
		messages => \@messages,
	);
}

sub serialize
{
	my $self = shift;

	my $io = Data::AMF::IO->new( data => q[] );
	
	$io->write_u16($self->version);
	$io->write_u16(scalar @{ $self->headers });
	$io->write_u16(scalar @{ $self->messages });

	for my $header (@{ $self->headers })
	{
		$io->write_utf8( $header->name );
		$io->write_u32( $header->must_understand );
		
		my $data;
		
		if ($self->version == 3)
		{
			my $formatter = Data::AMF::Formatter->new(version => 3)->new;
			$formatter->io->write_u8(0x11);
			$formatter->write($header->value);
			
			$data = $formatter->io->data;
		}
		else
		{
			$data = Data::AMF::Formatter->new(version => 0)->format($header->value);
		}
		
		$io->write_u32(bytes::length($data));
		$io->write($data);
	}

	for my $message (@{ $self->messages })
	{
		$io->write_utf8($message->target_uri);
		$io->write_utf8($message->response_uri);
		
		my $data;
		
		if ($self->version == 3)
		{
			my $formatter = Data::AMF::Formatter->new(version => 3)->new;
			$formatter->io->write_u8(0x11);
			$formatter->write($message->value);
			
			$data = $formatter->io->data;
		}
		else
		{
			$data = Data::AMF::Formatter->new(version => 0)->format($message->value);
		}

		$io->write_u32(bytes::length($data));
		$io->write($data);
	}

	return $io->data;
}

__PACKAGE__->meta->make_immutable;

__END__

=head1 NAME

Data::AMF::Packet - serialize / deserialize AMF message packet

=head1 SYNOPSIS

	use Data::AMF::Packet
	
	my $packet = Data::AMF::Packet->deserialize($data);
	my $data   = $packet->serialize;

=head1 DESCRIPTION

Data::AMF::Packet provides to serialize/deserialize AMF Packet.

AMF Packet is an extended format of AMF, and is used for Flash's HTTP based Remote Procidure Call (known as Flash Remoting).

=head1 SEE ALSO

L<Data::AMF>, L<Catalyst::Controller::FlashRemoting>

=head1 METHODS

=head2 serialize

Serialize Data::AMF::Packet object into AMF Packet data.

=head2 deserialize($amf_packet)

Deserialize AMF Packet, and return Data::AMF::Packet object.

=head1 ACCESSORS

=head2 version

return AMF Packet version.

=head2 headers

return AMF Packet header objects. (ArrayRef of L<Data::AMF::Header>)

=head2 messages

return AMF Packet Message objects. (ArrayRef of L<Data::AMF::Message>)

=head1 AUTHOR

Daisuke Murase <typester@cpan.org>

=head1 COPYRIGHT

This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the
LICENSE file included with this module.

=cut