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

Owner: Nobody in particular
Requestors: andy.jenkinson [...]

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

Subject: BUG: linefeeds in HTTP::Response->parse
Download (untitled) / with headers
text/plain 710b
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
Download linefeed.patch
text/x-diff 318b
*** 2010-02-03 16:02:31.000000000 +0000 --- 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
Download linefeed.t
text/x-perl 243b
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$/);

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to