AnyEvent-HTTP-Message
view release on metacpan or search on metacpan
lib/AnyEvent/HTTP/Message.pm view on Meta::CPAN
# stubs for read-only accessors
sub body { $_[0]->{body} }
sub headers { $_[0]->{headers} ||= {} }
# alias
sub content { $_[0]->body }
sub header {
my ($self, $h) = @_;
$h =~ tr/_/-/;
return $self->headers->{ lc $h };
}
# ensure keys are stored with dashes (not underscores) and lower-cased
sub _normalize_headers {
my ($self, $headers) = @_;
my $norm = {};
while( my ($k, $v) = each %$headers ){
my $n = $k;
$n =~ tr/_/-/;
$norm->{ lc $n } = $v;
}
return $norm;
}
1;
__END__
=pod
=encoding utf-8
=for :stopwords Randy Stauner ACKNOWLEDGEMENTS TODO featureful http cpan testmatrix url
annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata
placeholders metacpan
=head1 NAME
AnyEvent::HTTP::Message - Lightweight objects for AnyEvent::HTTP Request/Response
=head1 VERSION
version 0.302
=head1 SYNOPSIS
# don't use this directly
=head1 DESCRIPTION
This is a base class for:
=over 4
=item *
L<AnyEvent::HTTP::Request>
=item *
L<AnyEvent::HTTP::Response>
=back
=head1 CLASS METHODS
=head2 new
The constructor accepts either:
=over 4
=item *
a single hashref of named arguments
=item *
an instance of an appropriate subclass of L<HTTP::Message> (with an optional hashref of additional parameters)
=item *
or a specialized list of arguments that will be passed to L</parse_args> (which must be defined by the subclass).
=back
=head2 parse_args
Called by the constructor
when L</new> is called with
a list of arguments.
Must be customized by subclasses.
=head2 from_http_message
Called by the constructor
when L</new> is called with
an instance of a L<HTTP::Message> subclass.
Must be customized by subclasses.
=head1 ATTRIBUTES
=head2 body
Message content body
=head2 content
Alias for L</body>
=head2 headers
Message headers (hashref)
=head1 METHODS
( run in 0.568 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )