Gisle Aas writes:

Harald Joerg <[EMAIL PROTECTED]> writes:

As a fallback, HTTP::Response::parse could set the protocol to undef
if it turns out to be a three-digit number, assigning this value to
the code (after assigning to the message what was parsed as the code).

This is my preferred fix. Just make HTTP::Response::parse deal with what as_string spits out. I would just make it look at the string before spliting it. If it starts with /\d/ split in 2 instead of 3.

Patch is attached.

Should we try to add values for protocol every time when LWP creates
a HTTP::Response object?  Given this patch and the fact that nobody
complained so far, I don't think it's worth the effort...

BTW: Thanks for moving my other patch to HTTP::Message.  I had looked
at HTTP::Headers::clone, but missed the HTTP::Message base class.
--
Cheers,
haj


--- Response.pm.1.50    2004-12-02 21:36:42.437500000 +0100
+++ Response.pm 2004-12-03 22:10:27.421875000 +0100
@@ -35,5 +35,11 @@
 
     my $self = $class->SUPER::parse($str);
-    my($protocol, $code, $message) = split(' ', $status_line, 3);
+    my($protocol, $code, $message);
+    if ($status_line =~ /^\d{3} /) {
+       # Looks like a response created by HTTP::Response->new
+       ($code, $message) = split(' ', $status_line, 2);
+    } else {
+       ($protocol, $code, $message) = split(' ', $status_line, 3);
+    }
     $self->protocol($protocol) if $protocol;
     $self->code($code) if defined($code);

Reply via email to