Skip to content
Browse files

_status_with_entity_body()をインライン化

  • Loading branch information...
1 parent 8dd0c6e commit c9504c5cd75bd219a173aadd7939933ca2e49b73 Ryo Anazawa committed Feb 11, 2013
Showing with 16 additions and 20 deletions.
  1. +14 −13 lib/CGI/Header.pm
  2. +2 −7 lib/CGI/Header/PSGI.pm
View
27 lib/CGI/Header.pm
@@ -746,28 +746,29 @@ Any return values of the callback routine are ignored.
=item @headers = $header->flatten
-=item @headers = $header->flatten( $is_recursive )
-
Returns pairs of fields and values.
-This method flattens the Set-Cookie headers recursively by default.
-The optional C<$is_recursive> argument determines
-whether to flatten them recursively.
- my $header = CGI::Header->new( -cookie => ['cookie1', 'cookie2'] );
+ # $cookie1 and $cookie2 are CGI::Cookie objects
+ my $header = CGI::Header->new( -cookie => [$cookie1, $cookie2] );
$header->flatten;
# => (
- # 'Set-Cookie' => 'cookie1',
- # 'Set-Cookie' => 'cookie2',
- # 'Date' => 'Thu, 25 Apr 1999 00:40:33 GMT',
- # 'Content-Type' => 'text/html'
+ # "Set-Cookie" => "$cookie1",
+ # "Set-Cookie" => "$cookie2",
+ # ...
+ # )
+
+ $header->flatten(1);
+ # => (
+ # "Set-Cookie" => $cookie1,
+ # "Set-Cookie" => $cookie2,
+ # ...
# )
$header->flatten(0);
# => (
- # 'Set-Cookie' => ['cookie1', 'cookie2'],
- # 'Date' => 'Thu, 25 Apr 1999 00:40:33 GMT',
- # 'Content-Type' => 'text/html'
+ # "Set-Cookie" => [$cookie1, $cookie2],
+ # ...
# )
=item $header->as_string
View
9 lib/CGI/Header/PSGI.pm
@@ -22,7 +22,8 @@ sub psgi_header {
my $status = $header->delete('Status') || '200';
$status =~ s/\D*$//;
- if ( _status_with_no_entity_body($status) ) {
+ # status with no entity body
+ if ( $status < 200 || $status == 204 || $status == 304 ) {
$header->delete( $_ ) for qw( Content-Type Content-Length );
}
@@ -64,12 +65,6 @@ sub psgi_redirect {
);
}
-# copied from Plack::Util
-sub _status_with_no_entity_body {
- my $status = shift;
- return $status < 200 || $status == 204 || $status == 304;
-}
-
1;
__END__

0 comments on commit c9504c5

Please sign in to comment.
Something went wrong with that request. Please try again.