AnyEvent-HTTP-Message

 view release on metacpan or  search on metacpan

lib/AnyEvent/HTTP/Message.pm  view on Meta::CPAN

# vim: set ts=2 sts=2 sw=2 expandtab smarttab:
#
# This file is part of AnyEvent-HTTP-Message
#
# This software is copyright (c) 2012 by Randy Stauner.
#
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
#
use strict;
use warnings;

package AnyEvent::HTTP::Message;
{
  $AnyEvent::HTTP::Message::VERSION = '0.302';
}
# git description: v0.301-3-ge92f3a7

BEGIN {
  $AnyEvent::HTTP::Message::AUTHORITY = 'cpan:RWSTAUNER';
}
# ABSTRACT: Lightweight objects for AnyEvent::HTTP Request/Response

use Carp ();
use Scalar::Util ();


sub new {
  my $class = shift;

  my $self;
  if( ref($_[0]) eq 'HASH' ){
    # if passed a single hashref take a shallow copy
    $self = { %{ $_[0] } };
  }
  elsif( Scalar::Util::blessed($_[0]) && $_[0]->isa('HTTP::Message') ){
    # allow an optional second hashref for extra params
    $self = $class->from_http_message(@_);
  }
  else {
      # otherwise it's the argument list for http_request()
    $self = $class->parse_args(@_);
  }

  # accept 'content' as an alias for 'body', but store as 'body'
  $self->{body} = delete $self->{content}
    if exists $self->{content};

  $self->{body} = ''
    if !defined $self->{body};

  $self->{headers} = $self->{headers}
    ? $class->_normalize_headers($self->{headers})
    : {};

  bless $self, $class;
}

sub _error {
  my $self = shift;
  @_ = join ' ', (ref($self) || $self), 'error:', @_;



( run in 0.714 second using v1.01-cache-2.11-cpan-5b529ec07f3 )