Debian Codegraph @

debian/patches/header_additive

raw
1 From: Frank Lichtenheld <[email protected]>
2 Date: Tue, 3 Jun 2008 21:29:53 +0000
3 Subject: Fix header() to act according to documentation when called more than
4 once.
5
6 ---
7 lib/REST/Application.pm | 4 ++--
8 t/01-basic.t | 4 +++-
9 2 files changed, 5 insertions(+), 3 deletions(-)
10
11 diff --git a/lib/REST/Application.pm b/lib/REST/Application.pm
12 index 4070f5a..7298ef0 100644
13 --- a/lib/REST/Application.pm
14 +++ b/lib/REST/Application.pm
15 @@ -305,9 +305,9 @@ sub header {
16 # Arguments can be passed in as a hash-ref or as an even sized list.
17 if (@_) {
18 if (@_%2 == 0) { # even-sized list, must be hash
19 - %{ $self->{__header} } = @_;
20 + %{ $self->{__header} } = ( %{$self->{__header}}, @_ );
21 } elsif (ref($_[0]) eq 'HASH') { # First item must be a hash reference
22 - $self->{__header} = shift;
23 + %{ $self->{__header} } = ( %{$self->{__header}}, %{$_[0]} );
24 } else {
25 croak "Expected even-sized list or hash reference.";
26 }
27 diff --git a/t/01-basic.t b/t/01-basic.t
28 index b587dca..49a1574 100644
29 --- a/t/01-basic.t
30 +++ b/t/01-basic.t
31 @@ -283,8 +283,10 @@ BEGIN {
32 my %hash = $rest->header();
33 is_deeply(\%hash, {}, "Retrieving default header values.");
34 $rest->header(-type => 'text/html', -foobar => 5);
35 + $rest->header(-baz => 10);
36 %hash = $rest->header();
37 - is_deeply(\%hash, {-type => 'text/html', -foobar => 5}, "Retrieving custom header values.");
38 + is_deeply(\%hash, {-type => 'text/html', -foobar => 5, -baz => 10},
39 + "Retrieving custom header values.");
40 }
41
42 # TEST: resetHeader()