Subject: | HTTP::Response message |
Currently, the as_string method of HTTP::Response includes the HTTP status message (through HTTP::Status based upon the HTTP response code) in the status line irrespective of whether an alternate message has been defined. This is problematic in that it does not readily allow inheritance and extension of the HTTP::Response class for HTTP-like communication protocols, such as RTSP.
Attached is a simple patch which includes the HTTP status message only if no alternate message is defined.
diff -Naur libwww-perl-5.803.orig/lib/HTTP/Response.pm libwww-perl-5.803/lib/HTTP/Response.pm
--- libwww-perl-5.803.orig/lib/HTTP/Response.pm 2004-12-12 02:13:22.000000000 +1100
+++ libwww-perl-5.803/lib/HTTP/Response.pm 2005-10-04 16:13:09.926053392 +1000
@@ -112,8 +112,7 @@
my $status_line = "$code";
my $proto = $self->protocol;
$status_line = "$proto $status_line" if $proto;
- $status_line .= " ($status_message)" if $status_message ne $message;
- $status_line .= " $message";
+ $status_line .= length $message ? " $message" : " $status_message";
return join($eol, $status_line, $self->SUPER::as_string(@_));
}