Skip Menu |

This queue is for tickets about the HTTP-Message CPAN distribution.

Report information
The Basics
Id: 54266
Status: resolved
Priority: 0/
Queue: HTTP-Message

People
Owner: Nobody in particular
Requestors: andy.jenkinson [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: BUG: linefeeds in HTTP::Response->parse
Hi there, I've just discovered a problem in the handling of newlines in the HTTP::Response "parse" method. Basically, the HTTP specification defines the use of CRLF to indicate a newline whereas this method expects only LF. The bug does not appear to affect the equivalent method in HTTP::Message, which processes CRLF correctly. The issue manifests as $response->status_line having a CR on the end. It affects situations where the method is used to parse "real" HTTP spec compliant web server responses (which typically use CRLF). It does not occur when parsing the default output from the HTTP::Response->as_string method, which uses LF instead of CRLF. I've attached a patch and test. Cheers, Andy
Subject: linefeed.patch
*** Response.pm 2010-02-03 16:02:31.000000000 +0000 --- Response.pm.new 2010-02-03 16:43:00.000000000 +0000 *************** *** 30,35 **** --- 30,36 ---- $status_line = $str; $str = ""; } + $status_line =~ s/\r\z//; my $self = $class->SUPER::parse($str); my($protocol, $code, $message);
Subject: linefeed.t
use strict; use Test; use HTTP::Response; plan tests => 2; my $response = HTTP::Response->new(200); ok($response->status_line !~ m/\r$/); $response = HTTP::Response->parse($response->as_string("\r\n")); ok($response->status_line !~ m/\r$/);