-
-
Save anonymous/e984a8b25b0365dc0cfb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/Headers.pm b/lib/Mojo/Headers.pm | |
index 320d4a4..cdac39b 100644 | |
--- a/lib/Mojo/Headers.pm | |
+++ b/lib/Mojo/Headers.pm | |
@@ -20,9 +20,14 @@ my %NORMALCASE = map { lc() => $_ } ( | |
qw(Upgrade User-Agent Vary WWW-Authenticate) | |
); | |
for my $header (values %NORMALCASE) { | |
- my $name = lc $header; | |
+ my $name = my $key = lc $header; | |
$name =~ y/-/_/; | |
- monkey_patch __PACKAGE__, $name, sub { shift->header($header => @_) }; | |
+ monkey_patch __PACKAGE__, $name, sub { | |
+ my $self = shift; | |
+ $self->{headers}{$key} = [@_] and return $self if @_; | |
+ return undef unless my $headers = $self->{headers}{$key}; | |
+ return join ', ', @$headers; | |
+ }; | |
} | |
sub add { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment