Skip to content

Commit

Permalink
fixed cloning bug in Mojo::Headers
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 13, 2013
1 parent f57a325 commit 49fddaf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -8,6 +8,7 @@
- Fixed bug in Mojo::Headers that prevented multiline headers from being
parsed correctly.
- Fixed multiline header support in hash representation of Mojo::Headers.
- Fixed cloning bug in Mojo::Headers.

3.89 2013-03-04
- Improved documentation.
Expand Down
7 changes: 2 additions & 5 deletions lib/Mojo/Headers.pm
Expand Up @@ -39,11 +39,8 @@ sub add {
}

sub clone {
my $self = shift;
my $clone = $self->new;
$clone->{headers}{$_} = [@{$self->{headers}{$_}}]
for keys %{$self->{headers}};
return $clone;
my $self = shift;
return $self->new->from_hash($self->to_hash(1));
}

sub from_hash {
Expand Down
2 changes: 2 additions & 0 deletions t/mojo/headers.t
Expand Up @@ -110,6 +110,8 @@ $clone = $headers->clone;
$clone->expect('nothing');
is $headers->expect, '100-continue', 'right value';
is $clone->expect, 'nothing', 'right value';
$clone = Mojo::Headers->new->add(Foo => [qw(bar baz)])->clone;
is_deeply $clone->to_hash(1)->{Foo}, [[qw(bar baz)]], 'right structure';

# Multiline values
$headers = Mojo::Headers->new;
Expand Down

0 comments on commit 49fddaf

Please sign in to comment.