Skip to content

Commit

Permalink
Merge pull request #496 from plack/http-headers-fast
Browse files Browse the repository at this point in the history
use HTTP::Headers::Fast
  • Loading branch information
miyagawa committed Feb 14, 2015
2 parents 0f65be8 + 7db582b commit 8c2209f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ requires 'File::ShareDir', '1.00';
requires 'Filesys::Notify::Simple';
requires 'HTTP::Body', '1.06';
requires 'HTTP::Message', '5.814';
requires 'HTTP::Headers::Fast', '0.17';
requires 'Hash::MultiValue', '0.05';
requires 'Pod::Usage', '1.36';
requires 'Stream::Buffered', '0.02';
Expand Down
8 changes: 4 additions & 4 deletions lib/Plack/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use warnings;
use 5.008_001;
our $VERSION = '1.0034';

use HTTP::Headers;
use HTTP::Headers::Fast;
use Carp ();
use Hash::MultiValue;
use HTTP::Body;
Expand Down Expand Up @@ -120,7 +120,7 @@ sub headers {
my $self = shift;
if (!defined $self->{headers}) {
my $env = $self->env;
$self->{headers} = HTTP::Headers->new(
$self->{headers} = HTTP::Headers::Fast->new(
map {
(my $field = $_) =~ s/^HTTPS?_//;
( $field => $env->{$_} );
Expand Down Expand Up @@ -304,7 +304,7 @@ sub _parse_request_body {
sub _make_upload {
my($self, $upload) = @_;
my %copy = %$upload;
$copy{headers} = HTTP::Headers->new(%{$upload->{headers}});
$copy{headers} = HTTP::Headers::Fast->new(%{$upload->{headers}});
Plack::Request::Upload->new(%copy);
}

Expand Down Expand Up @@ -502,7 +502,7 @@ Returns C<REMOTE_USER> if it's set.
=item headers
Returns an L<HTTP::Headers> object containing the headers for the current request.
Returns an L<HTTP::Headers::Fast> object containing the headers for the current request.
=item uploads
Expand Down
12 changes: 6 additions & 6 deletions lib/Plack/Response.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ our $VERSION = '1.0034';
use Plack::Util::Accessor qw(body status);
use Carp ();
use Scalar::Util ();
use HTTP::Headers;
use HTTP::Headers::Fast;
use URI::Escape ();

sub code { shift->status(@_) }
Expand All @@ -30,13 +30,13 @@ sub headers {
my $headers = shift;
if (ref $headers eq 'ARRAY') {
Carp::carp("Odd number of headers") if @$headers % 2 != 0;
$headers = HTTP::Headers->new(@$headers);
$headers = HTTP::Headers::Fast->new(@$headers);
} elsif (ref $headers eq 'HASH') {
$headers = HTTP::Headers->new(%$headers);
$headers = HTTP::Headers::Fast->new(%$headers);
}
return $self->{headers} = $headers;
} else {
return $self->{headers} ||= HTTP::Headers->new();
return $self->{headers} ||= HTTP::Headers::Fast->new();
}
}

Expand Down Expand Up @@ -216,10 +216,10 @@ Sets and gets HTTP status code. C<code> is an alias.
$headers = $res->headers;
$res->headers([ 'Content-Type' => 'text/html' ]);
$res->headers({ 'Content-Type' => 'text/html' });
$res->headers( HTTP::Headers->new );
$res->headers( HTTP::Headers::Fast->new );
Sets and gets HTTP headers of the response. Setter can take either an
array ref, a hash ref or L<HTTP::Headers> object containing a list of
array ref, a hash ref or L<HTTP::Headers::Fast> object containing a list of
headers.
=item body
Expand Down

0 comments on commit 8c2209f

Please sign in to comment.