Skip to content

Commit b9f1c04

Browse files
authored
Merge pull request #88 from FGasper/issue_87_extra_cr_message
Trim trailing \r from status line so message() doesn't return it.
2 parents b7c38e8 + a462f3a commit b9f1c04

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/HTTP/Response.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ sub parse
3030
$str = "";
3131
}
3232

33+
$status_line =~ s/\r\z//;
34+
3335
my $self = $class->SUPER::parse($str);
3436
my($protocol, $code, $message);
3537
if ($status_line =~ /^\d{3} /) {

t/response.t

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use strict;
55
use warnings;
66

77
use Test::More;
8-
plan tests => 29;
8+
plan tests => 30;
99

1010
use HTTP::Date;
1111
use HTTP::Request;
@@ -84,7 +84,9 @@ is($freshness_lifetime, 10);
8484
ok($r->fresh_until); # should return something
8585
ok($r->fresh_until(heuristic_expiry => 0)); # should return something
8686

87-
my $r2 = HTTP::Response->parse($r->as_string);
87+
my $r2 = HTTP::Response->parse($r->as_string( "\x0d\x0a"));
88+
is( $r2->message(), 'OK', 'message() returns as expected' );
89+
8890
my @h = $r2->header('Cache-Control');
8991
is(@h, 2);
9092

0 commit comments

Comments
 (0)